我对Chrome有一个奇怪的问题。我有一些"go to no where link“
<a href="#">
这改变了iframe的内容,并且iframe页面中有更多的链接。
所以我的问题是,当我点击页面和iframe内部的"go to no where link“时,Chrome会自动滚动链接位置。
我能做些什么来取消这个效果吗?
以下是更改iframe内容的链接的内容之一:
var isChrome = (navigator.userAgent.indexOf("Chrome") >= 0);
function LoadFrame(url) {
var oFrame = document.getElementById("iframeBoxID");
if (isChrome) {
oFrame.style.visibility = "hidden";
oFrame.onload = function () {
oFrame.style.visibility = "visible";
};
}
oFrame.src = url;
}
$("#TestPage1").click(function () {
LoadFrame("../galleryControlTest/TestPage1.aspx");
changeFocusToIframe(this);
});
有没有什么东西我可以添加到脚本中,以取消此效果?在IE和FireFox中,这种情况不会发生。
发布于 2012-02-09 15:30:39
将return false
添加到您的onlick事件。
$("#TestPage1").click(function () {
LoadFrame("../galleryControlTest/TestPage1.aspx");
changeFocusToIframe(this);
return false;
});
发布于 2012-02-09 15:37:03
你可以去掉"#",就像这样写:<a href="">
https://stackoverflow.com/questions/9213740
复制相似问题