Well, since my journal is already a bitch fest... :)
I've been constructing a site. I decided to use the <base href="...">
to _try_ simplify things in my documents. This is fine and dandy, except for named hrefs (i.e. links to items like #top
).
When using base
, named hrefs will only point to named refs on the base
page. I decided to try and solve things with javascript. Here's what i came up with:
code.js:
function namedRef(strLink, strText) {
var intPosition = document.location.href.indexOf("#");
if (intPosition < 0) {
intPosition = document.location.href.length;
}
return "<a href=\"" + document.location.href.substring(0, intPosition) + "#" + strLink + "\">" + strText + "<" + "/a>";
}
somewhere in the html file:
<script type="text/javascript">
document.write(namedRef('top', 'Top'));
</script>
This is great! It'll give me things like test.html#top
and if you've already clicked on a named href, it won't duplicate it. It even works in Netscape 4. It bungholios things for lynx though.
...There's one tine exception to things working in Netscape 4. It won't do links that end in a slash (that may not be the EXACT condition, but for what i know, it works on site/index.html
but not site/
)
Perhaps i should forget using the base
tag. It seems like it's more trouble than it's worth.