window.top.document.body.scrollTop无法在Chrome或FireFox中使用 [英] window.top.document.body.scrollTop not working in Chrome or FireFox

查看:211
本文介绍了window.top.document.body.scrollTop无法在Chrome或FireFox中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码将打开一个模式窗口。这适用于IE 8,但不适用于Chrome或FF。我是跨浏览器功能的新手。

 函数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;

$ / code>

任何人都可以帮助制作此代码Chrome& FF兼容?

我试着改变 window.top window.parent 但没有运气
另外,在编写多个浏览器时(我浏览过,但没有找到任何跨浏览器兼容性的规则),要记住的任何规则?


更新:

问题是,在IE中,这个模式窗口大概以屏幕大小的一半出现。在FF和Chrome中,模式窗口显示大约一美元硬币的大小。

解决方案

我推荐像chrispanda这样的jQuery建议。 jQuery有一个内置的滚动事件,其余的可以写在几行来操纵HTML / CSS。



http://api.jquery.com/


I have the code below that will open a modal window. This works in IE 8 but not in Chrome or FF. I am new to the world of cross browser functionality.

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

Can anyone help in making this code Chrome & FF compatible?
I tried changing window.top to window.parent but no luck Also, any rules to keep in mind when coding for multiple browsers (I have browsed through but didn't quite find any set of rules for cross browser compatibility)?

Update:
The issue is that in IE, this modal window appears in approximately half the screensize. In FF and Chrome, the modal window appears about the size of a dollar coin.

解决方案

I'd recommend jQuery like chrispanda has suggested. jQuery has a built in scroll event and the rest can be written in just a few lines to manipulate the html / css.

http://api.jquery.com/

这篇关于window.top.document.body.scrollTop无法在Chrome或FireFox中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆