PDA

View Full Version : Implementing 'jump to certain anchor' in Accordion Content script



jherdt
10-14-2010, 06:24 PM
1) Script Title:

Accordion Content script (v1.9)

2) Script URL (on DD):

http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm


3) Describe problem:

Im using the Accordion Content script (v1.9)
Some Accordions exceed the browers window height so that the jump to an implemented anchor (the accordions header) would be handy, as the user would not recognize the opening of that certain accordion.

i know that it is possible to jump to an anchor with

window.location.hash="anchorname";

but i am not able to implement it into DD's Accordion Content Script.

as i need to use the scripts OnClick function it is not possible to implement an anchor via href="#anchorname".

i would like to add a function to the onclick event, is that possible ?
onClick="ddaccordion.toggleone('headercl',1); return false"

how could i achieve it to jump to a certain anchor(as each of the accordions headers are my anchors) with the help of this js function

window.location.hash="anchorname";

pls excuse my bad grammar / language

thx in advance :)

ddadmin
10-15-2010, 06:23 AM
If I understand you correctly, you can call more than one function inside the onClick event handler just by separating each function with a semicolon. So in this case, something like:


onClick="ddaccordion.toggleone('headercl',1); window.location.hash="anchorname"; return false"

jherdt
10-15-2010, 01:05 PM
if i do so either the javascript stops working (the specific accordion wont collapse anymore) or the anchor does not work alhtough there is #anchorname added to the url.

i implemented it as followed:

&nbsp;<a href="#" onClick="ddaccordion.toggleone('headercl',4); window.location.hash='anchor5'; return false;" >about</a> &nbsp;


<!-- ACCORD CONTENTBOX #5 -->
<div class="headercl" id="anchor5">about

would it be possible to modify the script to wait a certain amount of ms and then jump to a specified anchor wich is unique to the accordions header ? like : header about always has the anchor "anchor5" or "about" to which the script will navigate via window.location.hash after tge user clicked.

This would be perfect as it would allow the user to click the menubar and then would be routed to the specified accordion which has already done its opening animation.


thx in advance :)