开发者

how to get scrollTop position of parent window

开发者 https://www.devze.com 2022-12-15 21:43 出处:网络
if (window.parent) { scrollTop = jQuery(window.parent).scrollTop(); } following code from iframe window throws permission denied.

if (window.parent) { scrollTop = jQuery(window.parent).scrollTop(); }

following code from iframe window throws permission denied.

this direct code (not jquery) too.

parent.documen开发者_如何学Ct.body.scrollTop

Is it possible to go around this problems? :)


No.

For security reasons, it is not possible to access a frame from a different domain.
Even though what you're doing is completely benign, you still can't do it.

However, try changing document.domain to be the same (or parent) domain of the parent window (if you know what it is); that might help.


Not easily if they're on different domains, which would appear to be the case if you're getting permission denied errors.

You can get around this if you have access to both pages by using the document.domain property.

0

精彩评论

暂无评论...
验证码 换一张
取 消