Javascript setTimeout does not work -


i understand question has been asked many times, cannot find solution problem despite searching google , stackoverflow , applying various attempts.

here's js:

 function redirect(id) { window.open("go.php?id=" + id, "_blank"); } function linkpop(id) { xmlobj = new xmlhttprequest(); xmlobj.open("get", "pop.php?id=" + id, false); xmlobj.send(); document.getelementbyid(id).style.fontsize = xmlobj.responsetext + "px"; document.getelementbyid(id).title = "clicked " + (xmlobj.responsetext - 18) + " times"; window.settimeout(function(){redirect(id);}, 2000); } 

everything works apart 2 second delay , opening of new page. can see i've tried closure has not helped. expect i've missed basic...

thanks help.

you trying open pop-up window. modern browsers have pop-up blockers prevent doing except in restricted circumstances, due past abuses of feature.

in particular, browsers typically allow pop-ups in direct response interaction (eg click) web page. timeout event not interaction, if fired in response earlier interaction, won't allowed open window default settings.

you can open pop-up straight away (you can try opening pop-under , focusing later bring front, although isn't reliable). or, better, forget pop-ups , simple redirect on current page.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -