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"/>
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
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
baseproperty.