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.
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 4, social media strategist at Nationwide, consumer electronics enthusiast, hair metal aficionado.
View complete bio.
View complete bio.
Recent Blog Posts 
Blog Archive