开发者

Use JavaScript to monitor change of a frame

开发者 https://www.devze.com 2023-03-01 23:19 出处:网络
I have a frameset on my server which hosts a top frame main menu which is on the same domain, and a bottom frame which the content is sometimes on the same domain and sometimes on a remote domain.

I have a frameset on my server which hosts a top frame main menu which is on the same domain, and a bottom frame which the content is sometimes on the same domain and sometimes on a remote domain.

I would like to monitor the bottom frame to see if it changes, and if it does change, what URL it went to. Is开发者_运维问答 there a way to do this using JavaScript?


If you have control over the content coming from your domain, you should be able to detect when the user is leaving your domain. You can catch normal link navigation by listening to click events, and add extra code to notify of navigation to any other ways the user may leave the page.

Once the frame is showing content from a remote domain, though, you won't be able to get any information out of it without co-operation from the content itself (which, even then, involves nasty cross-domain communication hacks). A frame pointing to a remote domain will not report any information about itself to your page, not even the current URL.


You should be able to bind to the load on the iframe and work with that.

0

精彩评论

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