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

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

  1. blither

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

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

  3. 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

  4. glenn

    i love you! thanks for posting this

  5. gammageek

    wonderful solution

  6. Piero

    Thanks!

  7. Richie

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