Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Dumb Javascript Question

Dumb Javascript Question
Thread Tools
Sage
Mac Elite
Join Date: Apr 2003
Location: SoCal
Status: Offline
Reply With Quote
Nov 22, 2005, 12:44 AM
 
(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?
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Nov 22, 2005, 05:37 PM
 
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
     
DeathMan
Mac Elite
Join Date: Aug 2001
Location: Capitol City
Status: Offline
Reply With Quote
Nov 24, 2005, 09:05 PM
 
Check out the Prototype library by Sam Stephenson (http://prototype.conio.net/), and http://script.aculo.us/ which builds on this. They've got a very abstracted set of tools that have some very easy controls. Add to it the Behavior scripts from Ben Nolan (http://bennolan.com/behaviour/) and you can easily add behaviors to elments based on the element's CSS selector.
     
clam2000
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Nov 25, 2005, 02:16 AM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:59 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,