Forum Moderators: open

Message Too Old, No Replies

Scriptaculous + Prototype - how to triger effect via url

Scriptaculous + Prototype - how to triger effect via url

         

peterbra

2:26 am on Dec 5, 2009 (gmt 0)

10+ Year Member



Hi guys,
I'm using Scriptaculous + Prototype on my pages.
+ one combo handler:

Effect.OpenUp = function(element) {
element = $(element);
new Effect.BlindDown(element, arguments[1] ¦¦ {});
}
Effect.CloseDown = function(element) {
element = $(element);
new Effect.BlindUp(element, arguments[1] ¦¦ {});
}
Effect.Combo = function(element) {
element = $(element);
if(element.style.display == 'none') { new Effect.OpenUp(element, arguments[1] ¦¦ {}); }
else { new Effect.CloseDown(element, arguments[1] ¦¦ {}); }
}

My question is: How can i trigger BlindUp directly from url ?

Sample of my page is:


<a href="javascript:Effect.Combo('section1', {duration: 1, scaleX: false, scaleContent: false});"><h1>Click here to open 1</h1></a>
<div id="section1" style="display: none;">
<p>Text....</p>
</div>
<a href="javascript:Effect.Combo('section2', {duration: 1, scaleX: false, scaleContent: false});"><h1>Click here to open 1</h1></a>
<div id="section2" style="display: none;">
<p>Text 2222.</p>
</div>

So I want to place a link on different page and when user clicks on it I want him directed to this page with only "section2" displayed.(Using BlindDown)...

whoisgregg

8:15 pm on Dec 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, peterbra!

One way to do this is to pass a value in the hash tag portion of the link, then setup a listener on the target page to check for valid hash values. Basically:

<a href="/link/to/page.html#section2">Section 2</a>

Then in an onload event for the target page, test for the values of

location.hash
and do your effects based on that.

I'd also set up a timeout to check for changes to that value, since a second click on a link to a different anchor value won't fire the onload event. So you have to poll for changes.

peterbra

6:41 am on Dec 8, 2009 (gmt 0)

10+ Year Member



Hi Greg,

Thanks for reply, but I'm very slow with JS..
Can you give me a bit more guidance how to make listener for hash values ?

Thanks again,
Peter