简体   繁体   English

iPad Safari按钮突出显示问题

[英]iPad Safari Button Highlight Issue

I have a Div that when clicked I would like it to change colour and then link change page. 我有一个Div,当我单击它时希望它更改颜色,然后链接更改页面。 I have managed to get the page change to work automatically with setTimeout(). 我设法使页面更改与setTimeout()自动一起工作。 I am currently using css to highlight the button with the :active state. 我目前正在使用CSS高亮显示:active状态的按钮。

When using this though the highlight is temperamental and doesn't give the desired result. 使用此功能时,虽然高光是气质的,但无法提供理想的效果。 I have also had to use ontouchstart="" to get this to work currently. 我还必须使用ontouchstart =“”才能使它当前正常工作。

Can anyone suggest a better way to make the div change colour on tap for a certain amount of time and then change page? 任何人都可以提出一种更好的方法来使div在一定时间内改变水龙头的颜色,然后更改页面吗?

Thanks in advance! 提前致谢!

Update: 更新:

The code I am using is along the lines of: 我使用的代码大致如下:

<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>
<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM