SomeoneS
SomeoneS

Reputation: 1279

Iframe links not to open in iframe

i have iframe that shows content from the page that is not mine. In that iframe exists some links. When user clicks on links, they open inside iframe. I want them to open in current window (parent window).

I have found solution to add

 target="_parent"

to links, but i cant do that, becouse iframed page is not mine, and i cant edit that page.

Is there some way to do this, to open links from iframe in parent window?

Or js/jquery code to find all links on that page and add them attribut target?

Upvotes: 0

Views: 435

Answers (1)

insertusernamehere
insertusernamehere

Reputation: 23570

Unfortunatley it is not possible to query the content of an <iframe> which origin is from a different server. The only thing what you could do is to "proxy" the page through a server-side script (with PHP or something) before outputting it:

  • request the page using "cURL" or something similar
  • parse the content for your needs (like setting the target-attribute on all links)
  • output it back to the page's iframe

Finally the <iframe> could look like this: <iframe src="myproxy.php"></iframe>

Upvotes: 3

Related Questions