I am attempting to write a jQuery script where whenever a link is clicked on a certain page, a video is appended to the body, the video plays, and THEN it goes to the link’s intended target.
So far, this is what I have:
HTML
<body>
<div id="videoHolder">
<a href="http://www.google.com">Google, as an example</a>
</div>
</body>
jQuery
window.onbeforeunload=function(event) {
$("#videoHolder").html(
'<video width="600" height="600" autoplay="autoplay">' +
'<source src="images/doors.mp4" type="video/mp4"></source>' +
'</video>');
setTimeout('window.location.href=' + $('a').attr(href), 5000);
}
You need to prevent the link from redirection first, I’ve modified your code to make it work below