Here is simple <a>
tag, which links to an exe file. The onClick
JavaScript event redirects the user to another webpage after 3 seconds.
<a href="http://www.example.com/download.exe"
onClick="setTimeout('window.location="/downloading.html"',3000);return true;">
LINK</a>
So it doesn't work because there are too many nested quotes.
The first quotes ""
are for the onClick
function.
The second quotes ''
are for the SetTimeout
function.
I need third quotes for the window.location function. I've tried using both ' and " but none work. The above syntax fails.
I can solve it by refactoring the JavaScript into a function, but there are reasons why I cannot implement that. Is there a solution to this?
EDIT:
The answers below did not quite work, but led me to the correct solution:
onClick="setTimeout('window.location=\'/downloading.html\'',3000);return true;"