TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Javascript, AJAX, E4X (http://www.talkphp.com/javascript-ajax-e4x/)
-   -   Open Accordion if Anchor Selected (http://www.talkphp.com/javascript-ajax-e4x/5183-open-accordion-if-anchor-selected.html)

buildakicker 12-22-2009 04:55 PM

Open Accordion if Anchor Selected
 
Hi all,

So I am sure this is possible, but not sure how to implement it.

I have a link on a page that when clicked opens another page that contains a list of items with subitems that are contained in a closed accordion. I would like to click on the first page's link and have it load the second page and open the corresponding accordion list.

For example:
HTML Code:

<a href="link1.html#acord1>Link 1</a>, found on page.html, opens link1.html and anchors to #acord1. #acord1, by default, is a closed accordion. How can I have #acrod1 an open accordion when I click on the link1.html#acord1 on page.html?
There are multiple selections on link1.html... #acord1, #acord2, #acord3... etc...

Thanks!

adamdecaf 12-23-2009 01:40 AM

> I would like to click on the first page's link and have it load the second page and open the corresponding accordion list.

I'm going to assume that the <a>'s are set up similar to this.

Code:

<a href="about.php#contact">Contact</a>
 <a href="about.php#work">Our Projects</a>

javascript Code:
window.onload = function () {
   var hash = window.location.hash.substr(1);

  // You grab the assoicated element with the hash gathered from
  // [url]http://domain.tld/about.php#contact[/url]
  // If you're going to assign multiple css properties then I would
  // suggest creating a variable and putting in multiple statements.
   document.getElementById(hash).style.height = '250px';

  // Or
  var elm = document.getElementById(hash);
      elm.style.height = '250px';
      elm.style.border = '1px solid 000000';
      elm.style.cursor = 'pointer';
}


All times are GMT. The time now is 07:56 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0