What I'm trying to achieve is this:
By appending an anchor to the end of the URL
(eg. test.htm#anchor1)
I want javascript then to display ONLY the div on the page with the corresponding ID value 'anchor1'
I've tried the following code, but I'm getting errors:
------------------------------------------------
<html>
<head>
<script language="javascript">
<!--
pageAnchor = window.location.search;
function displayAnchor(anchor) {
if (anchor.style.display == "") anchor.style.display = "none";
else anchor.style.display == "";
return false;
}
-->
</script>
</head>
<body onload="return displayAnchor(pageAnchor);">
<div id="anchor1" style="display: none; background-color: red;">
test anchor
</div>
<div id="anchor2" style="display: none; background-color: blue;">
test anchor 2
</div>
</body>
</html>
By appending an anchor to the end of the URL
(eg. test.htm#anchor1)
I want javascript then to display ONLY the div on the page with the corresponding ID value 'anchor1'
I've tried the following code, but I'm getting errors:
------------------------------------------------
<html>
<head>
<script language="javascript">
<!--
pageAnchor = window.location.search;
function displayAnchor(anchor) {
if (anchor.style.display == "") anchor.style.display = "none";
else anchor.style.display == "";
return false;
}
-->
</script>
</head>
<body onload="return displayAnchor(pageAnchor);">
<div id="anchor1" style="display: none; background-color: red;">
test anchor
</div>
<div id="anchor2" style="display: none; background-color: blue;">
test anchor 2
</div>
</body>
</html>