3

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: Jquery 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?

Community
  • 1
  • 1
Timotei
  • 1,909
  • 2
  • 22
  • 31
  • Are the frames in the same domain? – Nick Craver Jun 20 '10 at 14:01
  • @Nick: No. The frame contains a textbox, which will have introduced (by the user) an URL. The bottom frame will browse to that location. – Timotei Jun 20 '10 at 14:20
  • 2
    I don't think you're going to be able to do this, for security reasons it's prevented. You could set the frame's domain and poll the frame, but not get an event when it changes. – Nick Craver Jun 20 '10 at 14:33
  • @Nick: you were right: http://stackoverflow.com/questions/1222687/jquery-permission-denied-different-domain-name . Thanks anyway. – Timotei Jun 20 '10 at 20:18

1 Answers1

2

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 :)

lsouza
  • 2,448
  • 4
  • 26
  • 39
  • It doesn't work. After I read another bunch of documents it seems impossibe to do what I want because of some security policies. : http://stackoverflow.com/questions/1222687/jquery-permission-denied-different-domain-name – Timotei Jun 20 '10 at 20:14