how to create a url that will open hidden divs

Giganews Newsgroups
Subject: how to create a url that will open hidden divs
Posted by:  snorq (ragamoff…@gmail.com)
Date: Thu, 16 Apr 2009

Hi, all. I have a page that uses javascript and the "display" style
property to show and hide divs. I want to be able to create a URL that
people can click to open up the page with a certain div showing. Any
suggestions on how to do that?

Below is some sample code from the site. Is there a way craft a URL
that will open the page with, say, the section2 div showing...?

(Note that my skills aren't highly developed, so the code may not be
as efficient as it could be.)

Thanks for any help.

Below is some sample code from the site. Is there a way craft a URL
that will open the page with, say, the section2 div showing...?

(Note that my skills aren't highly developed, so the code may not be
as efficient as it could be.)

Thanks for any help.

------------------------
*FLAG SECTION 1 AS THE DEFAULT DIV TO SHOW*
function initialSection() {
      document.currentSection = eval('document.getElementById
("section1")');
}

*SHOW THE NEW DIV, FLAG IT, HIDE THE OTHERS*
function show(selectedSection) {
      document.newSection = eval('document.getElementById
(selectedSection)');
      if (document.newSection.style.display == "none") {
              document.newSection.style.display = "inline";
              document.currentSection.style.display = "none";
      }
      document.currentSection = document.newSection;
}

*LINKS FOR SHOWING DIFFERENT SECTIONS*
<A  onClick="show('section1')">section1</A>
<A  onClick="show('section1')">section2</A>
<A  onClick="show('section1')">section3</A>

*THE DIVS*
<DIV id="section1" style="display: inline">
<DIV id="section2" style="display: none">
<DIV id="section3" style="display: none">

Replies