最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to get scrollTop position of parent window - Stack Overflow

programmeradmin3浏览0评论

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

following code from iframe window throws permission denied.

this direct code (not jquery) too.

parent.document.body.scrollTop

Is it possible to go around this problems? :)

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

following code from iframe window throws permission denied.

this direct code (not jquery) too.

parent.document.body.scrollTop

Is it possible to go around this problems? :)

Share Improve this question edited Jan 4, 2010 at 14:47 SLaks 889k181 gold badges1.9k silver badges2k bronze badges asked Jan 4, 2010 at 14:46 DanilDanil 1,8931 gold badge21 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

No.

For security reasons, it is not possible to access a frame from a different domain.
Even though what you're doing is pletely 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)

  1. 暂无评论