Delay For Open Popup Ad Onclick

I have 2 ad popups that open if a user click on aletbox.
I’m try for apply a delay for 1 popup ad code, this is the code:

<script type="text/javascript">
var uid = 'XXXXX';
var wid = 'XXXXX';
</script>
<script type="text/javascript" src="http://xxxx.xxxxxx.net/pop.js"></script>

Normally works perfect but if I apply a setTimeout not works.

<script>
setTimeout(function(){
var s = document.createElement('script');
s.src = 'http://example.com/some/script.js';
document.head.appendChild(s);
}, 2000);
</script>

Some ideas?

Is the script no longer popping the ads or is it the timer that isn’t working?

I don’t know if it’s because you buried the function anonymously within the setTimeout, personally I would create the script externally, bury the function anonymously there, reference it in html, then call the function in setTimeout as such:

setTimeout(“fname()”, 2000);

If I’m totally off topic or have a dumb answer I’m sorry I may have misunderstood.

Edit: The way you passed a function into setTimeout, I would only use if I were passing parameters without calling the function.

Why are you writing your setTimeout to work in Internet Explorer THREE.

All more modern browsers expect a functin as the first parameter and not a string and have to eval() the string.

setTimeout(fname,2000);

Oh thanks! Yeah it won’t work if you pass it as a string, Referenced a bad part of my code and should have tested that first, sorry!

Thanks for the reply.
With DOMReady and setTimeout to 0 seconds works better, I can do about 300 impressions with second popup, with the first popup I do about 1000.
I tried without eval() but not open nothing.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.