I'm not sure, but I suspect you're looking for a way of making a certain link appear "active" in a navigation bar or frame. I use this as a general purpose script, calling it from the navigation frame links with the onclick event, like so:
- Code: Select all
<a href="thatPage" target="myFrame" onclick="selectLink(document.anchors[0])"
and here's the script:
- Code: Select all
<script language="javascript" type="text/javascript">
var currentSelection;
function selectLink(newSelection) {
/*reset previously selected link*/
if (currentSelection){
currentSelection.style.fontWeight='normal';
}
newSelection.style.fontWeight='bold';
newSelection.hideFocus=true; /*Hide selection border*/
currentSelection=newSelection;
try{
document.parent.getElementById('myFrame').focus();
}
catch(e){ /*some browsers don't support focus*/
;
}
}
</script>
If this is what you're looking for then include the script in your navigation frame and trigger it with an
- Code: Select all
onLoad
event.
One tricky aspect I haven't yet found a great solution to is that I can't reference the anchors by name (like
- Code: Select all
selectLink(this)
or
- Code: Select all
selectLink('guestbook')
). I'm forced to access the anchor array by numerical index (above I'm selecting the first anchor on that page), and that makes moving things really awkward. Maybe somebody else can shed some light on that issue?
Good luck, hope this helps.
/shel