下面的代码将打开一个模态窗口。这在IE8中有效,但在Chrome或FF中不起作用。我是新世界的跨浏览器功能。
function ShowModal(WindowID,FramesetID)
{
window.onscroll = function () { window.top.document.getElementById(WindowID).style.top = window.top.document.body.scrollTop; };
window.top.document.getElementById(WindowID).style.display = "block";
window.top.document.getElementById(WindowID).style.top = document.body.scrollTop;
widthv=parseInt(parseInt(screen.width)/1.50);
heightv=parseInt(parseInt(screen.height)/1.50);
window.top.document.getElementById(FramesetID).style.width=widthv;
window.top.document.getElementById(FramesetID).style.height=heightv;
}有人能帮助使这个代码Chrome & FF兼容吗?
我尝试过将window.top更改为window.parent,但也没有运气,在为多个浏览器编写代码时有什么规则要记住(我已经浏览过,但没有找到任何跨浏览器兼容性的规则)?
更新:
问题是,在IE中,这个模式窗口大约显示在屏幕大小的一半。在FF和Chrome中,模式窗口显示的大小约为一美元硬币。
发布于 2013-09-23 13:18:01
另一种解决办法是:
(document.documentElement.scrollTop || document.body.scrollTop)https://stackoverflow.com/questions/7435843
复制相似问题