I have to load outside server URL within iframe which has some links, when user clicks on a link it opens outside the iframe. But I want to open it within the same iframe.
How is it possible?
I have to load outside server URL within iframe which has some links, when user clicks on a link it opens outside the iframe. But I want to open it within the same iframe.
How is it possible?
You should specify target name of the iframe.
<iframe src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="http://www.w3schools.com" target="iframe_a">www.google.com</a></p>
Links in documents loaded in iframes will, by default, open in the same frame.
If the document overrides that default behaviour (e.g. with target="_top"
) then the document will load elsewhere.
There is no way for the document containing the frame to change that behaviour (of the document loaded into the frame) if it is from an "outside server" since security restrictions prevent interaction with the DOM of documents form other origins.
You can not influence an iframe with a source on a different domain.
If it was on the same domain you could remove the target blank with javascript, but since its in a different domain you have no influence over the html.
Hope that helps and saves you countless hours trying the impossible.
You will need to set the target=_self
attribute in the link like this:
<a href="http://google.com/" target="_self">Google</a>
but if you are loading an external website you have no control over this may not be possible.
checkout the _target attribute on a hyperlink: http://www.w3schools.com/tags/att_a_target.asp you want "_self" e.g.
<a href="#" target="_self">link</a>