Reputation: 1
I am trying to use inline javascript to set a timeout for a link I am calling on my website:
<a href="javascript:setTimeout(()=>{window.location = 'thankyou.html' },2500);" class="burst_1 btn">Elementary School Camp</a>
It works in Chrome but not in Firefox or Internet Explorer. I tried to search online for alternatives but nothing has worked for me so far. I need a timeout because the buttons I am using on my site have a fireworks effect and I'd like visitors to see the effect for a few seconds before they get sent to the link page.
Or is there a better way to achieve what I am trying to do? Open to suggestions.
Upvotes: 0
Views: 125
Reputation: 18473
Replace <a href="javascript:...">
by <a href="#" onclick="...">
:
function waitThenNavigateTo (newLocation) {
setTimeout(() => {
window.location = newLocation;
}, 1000);
}
<a href="#" onclick="waitThenNavigateTo('http://example.com')">Click me!</a>
Upvotes: 2