Potato Lord
Potato Lord

Reputation: 11

Open link in iframe?

How can I make it so that when I click on another page in an iframed it opens within the iframe? I own both the website being iframed and the site with the iframe, so if I need to do something with the configuration of either that is fine. Thanks for your time!

Upvotes: 1

Views: 1236

Answers (2)

Silverhoft
Silverhoft

Reputation: 1

On the site that you are embedding the iframe on, enter this code:

<iframe src="Your iframe url" width="100%" height="100%" name="search_iframe"></iframe>

On the site within the iframe insert this code, and make sure the url is the other link you want to redirect to in the iframe:

<html><a href="Other site url" target="search_iframe">Link_name</a></html>

This should let you redirect in an iframe, but remember to add the href code for each link, otherwise it will open the link outside of the iframe.

Upvotes: -1

Quentin
Quentin

Reputation: 944069

That is the default behaviour.

So don't:

  • Use JavaScript to trigger non-standard link behaviour
  • Use a target attribute on the link
  • Use a target attribute on a <base> element
  • Use an CSP to block the page from being loaded in a frame
  • Use an X-Frame-Options header to block the page from being loaded in a frame

Upvotes: 3

Related Questions