views:

15

answers:

1

I have an iframe from an external source. I want to alter it (with javascript) so all links are opened with another absolute URL. I'm assuming the best approach is to modify the base property (element)

For example, assuming I embed stackoverflow.com as: <iframe src="http://stackoverflow.com"/&gt;

I want that when a user clicks the links, for example <a id="nav-askquestion" href="/questions/ask">Ask Question</a>, they will be opened in http://mysite.com, for example http://mysite.com/questions/ask

A: 

This is entirely impossible due to the Same Origin Policy.

You would have to fetch the external HTML page using a proxy script on your local server. There is no other way of gaining access to the page's links or setting a base property.

Pekka