奇怪的是代码可以工作,并且在某一行以下没有任何工作,甚至没有警报,并且变量失去了价值!
代码很简单:
// retrieving scroll position from a hidden text input<br>
var scrollPos = document.getElementById("scrollPosition").value;
// at this point scrollPos value is a certain number :)
// so i'm successfully able to change the HREF accordingly! :)<br>
document.getElementById("page1").href = "page1.php?pos="+scrollPos;<br>
document.getElementById("page2").href = "page2.php?pos="+scrollPos;<br>
document.getElementById("page3").href = "page3.php?pos="+scrollPos; // same value to all!
document.getElementById("page4").href = "page4.php?pos="+scrollPos;<br>
// at some weird point scrollPos loses its value! :(
实际上,故障点之后没有任何效果,甚至没有警报(“测试”)!