Question : Javascript to toggle DIVs and scroll to anchor link IF there is an anchor link in URL

In IE, I would like to direct users (coming from another webpage) to an anchor link that is contained within 2 DIVs IF #anchor is in the URL. Otherwise, if  there is no #anchor in the URL, the page should display with all DIVs collapsed.

Disclaimer: I'm not a programmer but by default, a user who is responsible for an internal website, so I truly appreciate everyone' patience, brain juice, and guidance in advance!

This is what I'd like to accomplish:
If #myAnchor is in URL, then expand the 2 DIVs and go to #anchor,
Else, display page as normal.

I am all mixed up when it comes to pulling it all together in a script to accomplish this.

So far....

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
1. Expanding the DIVs
I am able to expand the two DIVs using this link in the body of the webpage but I really need this to be called from the URL.
 
<p class="bodytext"><a class="jumplink" href="javascript:toggleBlock('abc');toggleBlock('def')">

This is how toggleBlock works:
function toggleBlock(pstrID){
  var myDiv = document.getElementById('d' + pstrID);
  if (myDiv){
    if (myDiv.style.display == 'none'){
      showBlock(pstrID);
    } else{
      hideBlock(pstrID);
    }
  }
}
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
2. Determining if #anchor is in the URL.
An EE Expert was kind enough to explain check self.location for the anchor.tag using an onload event for the body...Also, I'm not sure if I need to insert this as another <body onload=...> in the body or in the head section.

I've found these 2 snippets of code but can't  pull it together in a function so I'm not able to test it:
    var MyPage=location.href.(/(.*)#.*/,"$1");
    location.href=myPage+thisID
    -----
    or
    
    <script type="text/javascript">
    function jump (url) {self.location.hash = url)}
    </script>

Answer : Javascript to toggle DIVs and scroll to anchor link IF there is an anchor link in URL

Something like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
function toggleBlock(pstrID){
  var myDiv = document.getElementById('d' + pstrID);
  if (myDiv){
    if (myDiv.style.display == 'none'){
      showBlock(pstrID);
    } else{
      hideBlock(pstrID);
    }
  }
}
window.onload=function() {
  if (location.hash) {
    toggleBlock('id1');
    toggleBlock('id2');
  }
}


If you have
<a name="anchor"></a> then the url will go there itself
Random Solutions  
 
programming4us programming4us