While I know I've still got tons to learn (just look at the nice table structure on this site, seeing as CSS naked day was yesterday), I've still been doing this stuff for six years or so now, and thanks to
a comment from Justin Mclean on his blog, I've just learned something comepletely new to me: the
base
tag.
I feel like a complete newbie (or n00b or newb, or however your preferred spelling goes). Basically, any relative links will be preceded by that listed in the
href
attribute. It appears to need to be a full http:// and so forth, but that's easily made dynamic (in CF - you'll have to consult your docs for other languages) with
cgi.server_name
or
cgi.http_host
(as Justin pointed out. Thanks Justin!)
So, now my question to you all: who else didn't know about this? Don't be shy - If I'm not too embarassed to share my ignorance, neither should you be!
Hey! Why don't you make your life easier and subscribe to the full post
or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate
wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!
Leave a comment
Oh, I forgot to put an example. It's use should look like:
<base href="
http://www.codeodor.com"/>
and then any relative links in the page will have than prepended to them.
Posted by
Sam
on Apr 06, 2007 at 08:03 AM UTC - 6 hrs
Just a note about that... we used to use Base-Target in a frame-set (where all the links in one frame [nav] would load into another frame via default target). Worked great until IE7. Apparently the Base Target stopped working in IE7 (at least for Frame-based-targets).
I think that might be a XHTML standars or something.
Posted by
Ben Nadel
on Apr 06, 2007 at 09:18 AM UTC - 6 hrs
It's funny I didn't know about it till I started using <a href="
http://developer.fusium.com/tools/ses.cfm">SESconveter</a>
And then I had the same "Wow never knew that was there" moment.
Posted by jeff
on Apr 06, 2007 at 10:10 AM UTC - 6 hrs
Yup, sesConverter brought that little tag to light for a lot of people.
I actually still use it, too.
http://www.erikv.com/ses Not sure how long that fusium page will remain up.
Posted by erikv
on Apr 06, 2007 at 11:33 AM UTC - 6 hrs
I learned exactly what the base tag did a few years ago when debugging an application that was scraping Yahoo!'s homepage and embedding it within the application's rendered output (this was just a test scenario, no Yahoo! content was harmed in any way).
Yahoo! included (and maybe still includes) a base tag so any relative links that belonged to my application and appeared after the scraped content got re-routed. Oops. Hello, base tag. Nice to meet you.
Posted by
Rob Wilkerson
on Apr 06, 2007 at 11:53 AM UTC - 6 hrs
That's a great story Rob!
Posted by
Sam
on Apr 06, 2007 at 11:59 AM UTC - 6 hrs
I was vaguely aware of the tag and, in theory at least, knew what it would do, but had never used it myself and was *totally* unprepared for its impact on what I was trying to do. Took me *hours* to figure out WTF was going on.
Posted by
Rob Wilkerson
on Apr 06, 2007 at 12:02 PM UTC - 6 hrs
I've known about the base tag for as long as I can remember. It also works well for certain situations when you're trying to embed like a java applet or swf from a different domain.
Posted by Brad
on Apr 06, 2007 at 12:49 PM UTC - 6 hrs
Thanks - got it now
Posted by Seamus Campbell
on May 26, 2007 at 10:06 AM UTC - 6 hrs
It's good to learn new tags that are out there and what they do, but I always strongly discourage the use of the <base> tag. It's nice if you're staging a site or moving from one server to another, but it can cause all kinds of unintended consequences down the road, especially if you end up doing anything serious with Flash or AJAX. It seems like all browsers handle the base tag differently, and relying on the <base> tag can cause a world of unintended frustration down the road.
Posted by
andy
on Jun 12, 2007 at 12:13 PM UTC - 6 hrs
Thanks for the heads up andy, it is definitely a good consideration. I still haven't used the base tag, but I think its because I got too used to doing it dynamically when I needed to.
Posted by
Sam
on Jun 12, 2007 at 01:36 PM UTC - 6 hrs
Leave a comment