The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> function runs first time then stops
1andyw
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th April 2024 - 03:21 AM