开发者

Detect frame location/content changed

开发者 https://www.devze.com 2023-01-03 22:15 出处:网络
I have the following situation. I have 2 frames (top and bottom). The upper frame monitors the current loaded page in the bottom frame. How can I know if the users changed the location of that frame (

I have the following situation. I have 2 frames (top and bottom). The upper frame monitors the current loaded page in the bottom frame. How can I know if the users changed the location of that frame (the url)? So I want to know when the user, press a link in that page, that goes somewhere.

I found something like this here: Detect element content changes with jQuery , but it doesn't help me (I think).

Could you give me some ideas?

Thanks, Timotei

EDIT: The bottom frame is on another domain, so according to this: Jq开发者_如何学运维uery permission denied - different domain name is not possible.

So, to put it other way, is there any method to "monitor" the pages a users surfs, using any other in-browser method?


You maybe can store the location of the iframe, then create a interval that will look if the SRC has changed.

var theSrc = document.getElementById('myframe').src;

setInterval(function(){
  if (document.getElementById('myframe').src != theSrc) {
    // the URL has changed
  }
}, 5000);

Hope it works :)

0

精彩评论

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