|
|
Dumb Javascript Question
|
|
|
|
Mac Elite
Join Date: Apr 2003
Location: SoCal
Status:
Offline
|
|
(Please forgive me, for I’m not too comfortable with Javascript or programming in general.)
On my blog, if you click on the Archives link on the left side, it’ll jump down to the Archives section at the very bottom of the page. You’ll notice that the word “Archives” gets highlighted, then the highlight fades away.
Now, this is the Javascript I use to achieve this (I think I got it from yourtotalsite.com’s Yellow Fade Technique tutorial). I’ve modified it quite a bit to suit my needs, but one thing I can’t figure out is how to make the script wait a little bit until it carries out DoFade (in other words, when somebody clicks on a jump link, I want the page to jump, wait a couple seconds, then do the fade effect). I know I have to use setTimeout(), but I don’t know where to put it. Any help, please?
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status:
Offline
|
|
For some reason I can't pll up the source of your webpage, but wherever your calling the DoFade function, change it to something like this:
setTimeout("DoFade()",5000);
|
Scott Genevish
scott AT genevish DOT org
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Aug 2001
Location: Capitol City
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Aug 2002
Status:
Offline
|
|
what you need to do to insert the delay is change this
Code:
function Highlight(target) {
// Get the target ID from the string that was passed to the function
var targetId = target.substring(target.indexOf('#')+1,target.length);
DoFade(StartFadeAt, targetId);
}
to
Code:
function Highlight(target) {
// Get the target ID from the string that was passed to the function
var targetId = target.substring(target.indexOf('#')+1,target.length);
setTimeout("DoFade("+StartFadeAt+","+ targetId+");",500);
}
where the 500 is how long of a delay you want
(1000 = 1 second)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|