function runs first time then stops |
function runs first time then stops |
1andyw |
Aug 30 2007, 05:21 PM
Post
#1
|
Group: Members Posts: 1 Joined: 30-August 07 Member No.: 3,679 |
Hi,
I have several articles on my home page marked with anchors. I compose a periodic email message listing the link to each new article. When the viewer moves to the home page article, a script highlights the h2 element with a yellow background. This works correctly on the first link in the email, but clicking subsequent links does not refresh the browser and the subsequent links do not change h2 background color. The article does scroll to the top of the page. I sure would like to understand why the script runs once but then stops. html CODE <body onload="highlight()"> <div class="art"><a name="workshops"></a><h2 id="workshops_heading">Workshops for Advocacy Groups</h2> <p>The Disability Advocacy Support Hub is providing no-cost workshops.</p> </div> The script CODE function highlight(){ var hasher, elname; if (location.hash){ hasher = (location.hash.slice(1)); elname = document.getElementById(hasher + "_heading"); elname.style.backgroundColor="yellow"; } } Thanks, Andy |
Lo-Fi Version | Time is now: 28th April 2024 - 03:21 AM |