mwbarry Posted January 30, 2012 Share Posted January 30, 2012 On my site I have written a script so that when the user clicks a link on the nav bar, the url change is delayed to make time for a fade away animation. It works perfectly in Safari, but when done with firebug opened in Firefox I get an error for the setTimeout function saying that, for example, 'services is not defined'. What does this mean and does anyone have any ideas on how to fix it? Here is the code: menu html code <li id="liservices"><a href="#" onclick="menuredirectdelay(this)" class="nav" id="services">services</a></li> delay javascript function menuredirectdelay(element) {setTimeout("menuredirect(" + element.id + ")", 1300);} function menuredirect(element) {var url = "http://www.thewebsite.com/" + element.id + ".php";window.location.assign(url);} Link to comment Share on other sites More sharing options...
Don E Posted January 30, 2012 Share Posted January 30, 2012 Instead of what you have, try this: setTimeout("menuredirect('element.id')", 1300); Link to comment Share on other sites More sharing options...
dsonesuk Posted January 31, 2012 Share Posted January 31, 2012 you have to pass the value as text between single quotes function menuredirectdelay(element) {setTimeout("menuredirect('" + element.id + "')", 1300);} the next function just needs to read the text value passed to it and insert that into the url, and not call the element id again function menuredirect(element) {var url = "http://www.thewebsite.com/" + element + ".php";window.location.assign(url);} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.