Larry Brister
asked on
Javascript timer not working
In the code below...
The timer is not waiting 7 seconds...
It is redirecting immediately
I need the delay
The timer is not waiting 7 seconds...
It is redirecting immediately
I need the delay
<script type="text/javascript">
window.onload = function () {
var foo = 'http://members.mywebsite.com/gp.aspx?enc=' + getParameterByName('enc');
//alert(foo);
setTimeout("window.location='" + foo + "'", 7000);
};
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
</script>
ASKER
Still goes directly to next page
No delay
No delay
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it...
And the alert was showing me a corrupted string in the url
Thanks
And the alert was showing me a corrupted string in the url
Thanks
Open in new window
https://jsfiddle.net/HainKurt/o5v22s1b/