This is what Shawn Morton would look like if he had been made of LEGO sMoRTy71.com -- the personal website of Shawn Morton
UPDATE: This blog has been retired as of August 2011. See this post for more information or connect with me on Twitter.
Monday, July 9, 2007
IFRAMEs and BASE HREFs
I was disappointed with how long it was taking the Twitter and Flickr badges to load on the home page of sMoRTy71.com, so I decided to go back in internet time and dust off a couple of old HTML friends: the IFRAME and the BASE HREF.

By putting both the Twitter and Flickr badges in separate IFRAMEs, the page will load and then wait for the content of the IFRAMEs to load. Before, the page would hang until both of the badges loaded.

Unfortunately, the Flickr badge wasn't as simple as just sticking the badge code in an IFRAME. Because all of the URLs are served via a script, I couldn't apply link targets to them. This meant that if you clicked on one of the photos in the badge, the Flickr page would load within the IFRAME. Not what I wanted.

After scratching my head for a bit, I remembered the BASE HREF and the fact that you can set a TARGET there. So I added the following code to the HEAD of the Flickr IFRAME HTML:

base href="" target="_parent"

This causes all links within the Flickr IFRAME to load within the parent window.

Now, the home page loads completely regardless of any issues with the badges. Not the most elegant solution, but it works.

About Shawn Morton

Married father of 6; VP of Social Media at JPMorgan Chase; gluten-free; gadget enthusiast; hair metal aficionado; #Movember man View more on LinkedIn.