eastboundr
eastboundr

Reputation: 1877

Would it be possible to intercept all redirects and open the contents in a new window/pop up?

So I have a page that contains an iframe. Inside the iframe, there are links that opens up new page in the same window (self.location.href) (window.open(urlstring,'false') etc...etc...

Is there a way that I could force all links inside this window to open up their contents in a new window/pop up? Overrides their redirect settings and without changing the code inside the iframe?

The reason I'm asking this is because that, I think the iframe page still references the parent window as their window, therefore, when the function like "window.self.open" was triggered, it took my whole parent window away...

Maybe anyway to embed the iframe as an separate window inside the page? Just not sure how to avoid the same window referencing...

Thanks!

Upvotes: 6

Views: 1430

Answers (2)

Patrick Miah
Patrick Miah

Reputation: 51

You could also add the target attribute to a base-tag within the header.

<base target="_blank">

This will be applied to all links as well.

Upvotes: 1

Ryan Kohn
Ryan Kohn

Reputation: 13509

You can set the links to open in a new window by adding target="_blank" to the a element (e.g. <a href="example.html" target="_blank">Example</a>).

If you want to have this applied to all links without touching the links themselves, you can include a jquery function to do it for you:

$("a").attr("target","_blank");

Upvotes: 1

Related Questions