Force All Links on a Page to Open In a New Window

A neat little tag that I used recently to force all of the links within an iFrame page to open in a new window without having to update each link manually:

This worked great for updating the links in a Facebook specific iFrame, that way I could pull in dynamic content without having to update the WordPress post links, widgets, etc. to include taget=”_blank”.

I had direct access to the iFrame source, but I also found a script that may allow you to do this from the top level page where you are calling the iFrame as well.


$(document).ready(function()
{
var baseTag= document.createElement('base');
baseTag.target = '_blank';
$("iframe html head").append(baseTag);
});

Speak Your Mind

*

CAPTCHA image
*