How to Make all Links Within an iframe or Google Gadget Open in a New Window

August 11, 2009 · 7 comments

Just made a Google gadget from the Twitter widget code and realized that all the links were opening within the Google gadget iframe.

This is no good. A quick and dirty solution for this…

If you need to have all links within an iframe or Google gadget use “base target”.

To do this you will need to add a head section to your gadget immediately after the “[CDATA[” part and add the “base target=”_blank”

basetarget

This will in most cases take care of the problem and make all links inside that iframe or Google gadget open up in a new window.

{ 7 comments… read them below or add one }

blither October 18, 2009 at 8:09 pm

Why are u the only one posting this as a solution…Possible SEO strategy in itself…
ummm
cause it doesn’t work

Amit November 25, 2009 at 11:14 am

This is really nice info.Thanks for such a wonderful post.

ss goh June 14, 2010 at 3:28 am

Man, you are superb.
One line of code is all that is needed to open a link in a new window from within an iframe.
The other people offering solutions got me on a wild goose chase and no straight forward solution.
Your’s the best.
Very grateful web developer here in Singapore.
SS Goh

glenn October 7, 2010 at 11:27 am

i love you! thanks for posting this

gammageek February 3, 2011 at 12:45 pm

wonderful solution

Piero July 11, 2011 at 7:48 am

Thanks!

Richie July 18, 2011 at 11:08 pm

Awsome dude, years trying to solve this issue, thanks a lot!!!

Leave a Comment

Previous post:

Next post: