2013-12-20 127 views
0

我有一个Div,单击时我希望它改变颜色,然后链接更改页面。我设法通过setTimeout()自动运行页面更改。我目前使用CSS来突出显示按钮:活动状态。iPad Safari按钮突出显示问题

当使用这个虽然高光是脾气,并没有给出所需的结果。我还必须使用ontouchstart =“”才能使其正常工作。

任何人都可以提出一个更好的方法来使div改变颜色在水龙头上一段时间,然后改变页面?

在此先感谢!

更新:

我使用的代码是沿着线:

<style type="text/css"> 
#button_RH_Pg1{ 
background-color:#FF0000; 
padding:10px; 
text-align:center; 
font-weight:bold; 
color:#FFFFFF; 
font-family:arial; 
cursor:hand; 
} 
#button_RH_Pg1:active{ 
background-color:#000000; 
} 
</style> 
<script> 
function page2load(){ 
document.getElementById('page1dis').style.display="none"; 
document.getElementById('page2dis').style.display="block"; 
} 
</script> 
<div id="page1dis"> 
<div id="button_RH_Pg1" onclick="page2load()">This is a button</div> 
</div> 
+1

我们不能没有看到代码帮助... – BenM

+0

只是示例代码更新 – KM123

+0

出于好奇,为什么不使用标准作为链接? – yochannah

回答

0
<style type="text/css"> 
div.button_RH { 
    background-color: #FF0000; 
    padding: 10px; 
    text-align: center; 
    font-weight: bold; 
    color: #FFFFFF; 
    font-family: arial; 
    cursor: hand; 
} 
</style> 
<script> 
var delay = 500; 
function pageload(button, targetpage) { 
    button.style.backgroundColor = "#000000"; 
    setTimeout(function() { 
    button.parentNode.style.display = "none"; 
    document.getElementById(targetpage).style.display = "block"; 
    button.style.backgroundColor = "#FF0000"; 
    }, delay); 
} 
</script> 
<div id="page1dis"> 
    <div class="button_RH" onclick="pageload(this, 'page2dis')"> 
    This is a button 
    </div> 
</div> 
+0

非常感谢!它的工作 – KM123