Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 712
eastboundr Avatar asked Jul 17 '12 17:07

eastboundr


1 Answers

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");
like image 188
Ryan Kohn Avatar answered Nov 13 '22 21:11

Ryan Kohn