I need to create a timer that closes a modal box and then jumps the url that was clicked on in the html.
What would be the best way to execute this?
I need to create a timer that closes a modal box and then jumps the url that was clicked on in the html.
What would be the best way to execute this?
add attribute rel to a links, for example rel=“open_modal” then
var links = document.getElementsByTagName('a');
for(var i = 0; i < links.length; i++)
{
if(links[i].getAttribute('rel') == 'open_modal')
{
links[i].onclick = function()
{
//code for open modal
var hrf = this.getAttribute('href');
setTimeout(function() {
//code for close modal
window.open(hrf, 'mywin', '_self');
}, 5000);
return false;
}
}
}
i hope this helps, if you use jQuery you can do this much easier, when I say much easier I mean with less code