SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Apr 2003
    Posts
    332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need to force reload

    Hi,

    I have numerous anchors on my home page. Periodically, I send an email with links to each article with an anchor. When the viewer of the email clicks on the first link, the home page loads, scrolls to the article and changes the article h2 element background to yellow. However, when the viewer clicks on subsequent links in the email, the home page scrolls to the new article but the h2 element background doesn't change on the new article and remains yellow on the previous article. It will change background's if I use the reload button.

    How can I force a reload with each change of article focus?

    html:
    Code:
    <body onload="highlight();">
    <div id="container">
    <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

  2. #2
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    body.onscroll = highlight;
    Matt Alexander
    Alexander Site Design

  3. #3
    SitePoint Addict
    Join Date
    Apr 2003
    Posts
    332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Matt,

    IE6 doesn't respond to 'onscroll'. FF works as desired. Any ideas about a work-a-round for IE6?

    Andy

  4. #4
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://snook.ca/archives/javascript/handling_onscroll/ ?

    Kind of a hack, but apparently it works.
    Matt Alexander
    Alexander Site Design

  5. #5
    SitePoint Addict
    Join Date
    Apr 2003
    Posts
    332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you.

    Andy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •