I have a small piece of javascript that I would like to use but need a delay before it’s activated.
function sglClick(url) {
window.setTimeout('location.href="http://'"+url",1500);
}
This is not working and I’m really stuck here.
Here is what I now have
function send(){
}
function sglClick(url) {
// window.location.href="http://"+url;
setTimeout(function send() { location.href = "http://" + url; },1500);
}
try this
This is using an anonymous function to house your code. It should take approx 1.5 seconds to fire. I say approx because JavaScript is single threaded, and other function calls/etc can actually make the interval fire at a slightly different time (but 9/10 this is a non-issue)
It is also assuming you’re sending things like this to the function
As your code is prefixing the argument with http://
I’ve always used this function as just simply setTimeout(), not as a method of the window object.