Reputation: 1
I am not a coder/programmer and I found a script I would like to use and I used my wysiwyg editor to try to make it work the best I could, but it still does not work the way I want maybe someone could help me.
The script:
<script type="text/javascript">
<!--
redirectTime = "5000";
redirectURL = "http://somesite.com";
function timedRedirect() {
setTimeout("location.href = redirectURL;",redirectTime);
}
// -->
</script>
<textarea name="TextArea1" id="TextArea1" onblur="timedRedirect() ;return false;" style="position:absolute;left:200px;top:390px;width:108px;height:108px;z-index:1;" rows="3" cols="9"></textarea>
With this this script I am trying to add an alert box to it, the script works (found it online), but when I try to add the alert to it triggers automatically not after the timer goes off. It should trigger the same time as the script. It show go alert box, url redirect at specified settimeout
.
If someone could help that would be great. I tried to script them to work to the best of my ability and was not able to. If someone could put an edited version of what I am trying to accomplish that would be great.
Upvotes: 0
Views: 178
Reputation: 782148
var redirectTime = 5000;
var redirectURL = "http://somesite.com";
function doRedirect() {
alert("We're about to redirect!");
window.location.href = redirectURL;
}
function timedRedirect() {
setTimeout(doRedirect, redirectTime);
}
Upvotes: 1