0

I'm making a website that has another website embedded in an object (a small box in my page). I'm looking for as solution that will allow me to hide this object when the webpage in the embedded object changes (i.e. the user clicks a link on that website)

The code I have below will only shows will create the embedded object but everything is static (i.e. the "src" will not change as the URL changes in the object).

<object data=http://www.website.com  width="600" height="400"> <embed id="test" src=http://www.website.com  width="600" height="400"> </embed> Error: Embedded data could not be displayed. </object>

Is there a way to look at the current URL of that object? I've been thinking about using something similar to location.href but I'm not sure how to implement this.

Thanks

Clifford
  • 88,407
  • 13
  • 85
  • 165
William Dao
  • 23
  • 1
  • 1
  • 4
  • 1
    Why don't you use an ` – SLaks Aug 01 '12 at 14:34
  • As @SLaks suggests I would use an iframe - but either way if this is **not your site** then you'll have issues due to the security layer in the browser between sites of different domains (e.g. you won't be able to manipulate/read content from it) - The better question is why do you want to alter the display of the content.. e.g. what is the purpose? (maybe there is a better solution) – scunliffe Aug 01 '12 at 14:41
  • possible duplicate of [How do I get the current location of an iframe?](http://stackoverflow.com/questions/44359/how-do-i-get-the-current-location-of-an-iframe) – epascarello Aug 01 '12 at 14:48
  • @scunliffe I don't think this is going to be a security issue (these are all internal websites). The only thing I'm looking for is to have the URL change. What I'm essentially trying to do is trying to mimic external logins from another website without using a complicated API. If I use an iframe, will it be able to see the URL change? Because with an embedded object, I can't see the "src" attribute change at all – William Dao Aug 01 '12 at 14:52

1 Answers1

0

Sorry, due to browser policy, you can not do that, you can only get iframe url if it open a page within your domain. For more information you can search "get iframe url" within stackoverflow

If your site is in the same domain, you think you can do like this

var url = http://www.website.com";
function checkChange(){
   if (document.getElementBydId('test').src != url){
      alert('page change');
   }
}

setInterval(checkChange, 1000);
James
  • 13,571
  • 6
  • 61
  • 83