SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question hide and show div

    hello,
    this is a function to hide and show div
    Code:
    function ToggleMaktoba (titleImg){
    		// the id of the content element from the id of the title element
    	var contentID = titleImg.id.replace (/title/, "content");
    	var contentDiv = document.getElementById (contentID);
    	
    	if (contentDiv.style.display == "none") {
    		titleImg.src = "images/collapse.gif";
    		contentDiv.style.display = "block";
    	}
    	else {
    		titleImg.src = "images/expand.gif";
    		contentDiv.style.display = "none";
    	}
    
    	return false;
    }
    the problem that i have is that this div is viewed on every page on the site,
    so if i hide it i want it to stay hidden even when navigating threw pages. if i choose to hide it, it stays hidden, and if i chose to show it, it stays shown. any help would be wonderful.
    thanks

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You'll have to set a cookie to remember that it's hidden, and read that cookie when each page loads to see if you need to hide the div again.

    http://www.quirksmode.org/js/cookies.html


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
  •