Forum Moderators: open
<a name="bookmark_1">Bookmark One</a>
<a name="bookmark_2">Bookmark Two</a>
You links would read <a href="bookmark_1">Go To Bookmark One</a> or if you are coming from a different page, the anchor would be <a href="widgets.com#Bookmark_1">Go To...</a>.
If your bookmarks are in the same line, there is no way ti really distinguish the target bookmark. If they are above one another, each bookmark should align with the top of the window when selected.
Marshall
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
div {
padding-top: 900px;
}
.activeLink {
background-color: #ffff00;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title>Example</title>
</head>
<body>
<a href="#link1" class="gotolink">Go to Link 1</a>
<a href="#link2" class="gotolink">Go to Link 2</a>
<a href="#link3" class="gotolink">Go to Link 3</a>
<div>
<a name="link1" id="link1">Link 1</a>
<a name="link2" id="link2">Link 2</a>
<a name="link3" id="link3">Link 3</a>
</div>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
var i, target;
var gotoLinks = YAHOO.util.Dom.getElementsByClassName('gotolink', 'a');
var targetLinks = [];
// Build the list of target links first (so we can reset them)
for (i = 0; i < gotoLinks.length; i++) {
target = document.getElementById(gotoLinks[i].href.split('#')[1]);
targetLinks[targetLinks.length] = target;
}
// targetLinks now contains all of the links that we link to
for (i = 0; i < gotoLinks.length; i++) {
YAHOO.util.Event.on(gotoLinks[i], 'click', function (e, t) {
var j;
var aname = this.href.split('#')[1];
for (j = 0; j < t.length; j++) {
YAHOO.util.Dom.replaceClass(t[j], 'activeLink', 'dormantLink');
}
YAHOO.util.Dom.replaceClass(aname, 'dormantLink', 'activeLink');
}, targetLinks);
}
});
</script>
</body>
</html>