FireFox和<a href="" scrolling="" to="" a="" page="" part="" like="" div=""

时间:2018-09-01 22:52:47

标签: javascript css firefox

="" I have a style for image button :

.sticky {
  position: fixed;
  top: 50px;
  width: 120%;
  z-index: 1;
}
@media screen and (min-device-width : 100px) and (max-width: 600px)  {
 .sticky{
 display:none;
 }
}

and script for these:

window.onscroll = function() {
    myFunction();

}

var backarrow = document.getElementById("back");
var sticky = backarrow.offsetTop;

function myFunction() {
  if (window.pageYOffset >= sticky) {
    backarrow.classList.add("sticky");
  } else {
    backarrow.classList.remove("sticky");
  }

}

it actually works! But I do not understand why Clicking is disabled for FireFox while other browsers do not have problems with it. z-index is set to 1 but other browsers are fine with it but FF. what I can do about it and how to fix it? Thank you very much who knows!

3 个答案:

答案 0 :(得分:0)

我只是为图像按钮链接做的:

<a href="#top"   <a href="#wrap" 

应该适用于任何浏览器。这甚至不是脚本。但可能不够我所拥有的CSS。

'>

<img alt="" class="mainlogo"  src='data:image/png;base64,<?php echo base64_encode(file_get_contents("******.png")); ?> '>

   <button class="right"> <a href="#wrap" class="next" onclick="plusSlides(1)"> <img alt="" id="forward" class="logo" style='max-width: 40px;' src='data:image/png;base64,<?php echo base64_encode(file_get_contents("*****/Pictur3.png")); ?>  '> </a> </button>

答案 1 :(得分:0)

我所做的是

<button onClick="location.href = '#wrap'" 

对于按钮元素 但对于

<a href 

它不起作用,所以我正在寻找解决方案

 <a href="#top" 

对FireFox没有帮助

答案 2 :(得分:0)

我解决了问题!!!!!!! 我所做的是将我的按钮ID用于我的由img id插入的jquery脚本。因此,整个按钮将只向下滚动图像,因此我可以实现

 <button onClick="location.href = '#top'" 

已插入任何  <img onclick<href onclick  我尝试过但不起作用的事件。 希望它也能帮助任何人,例如:)