Jump to content

Timeout On Javascript


private_guy

Recommended Posts

Hi there,

 

I'm trying to add a timeout to the below JavaScript from Zango but its not working. Here is the orginal source:

<html>
<!-- POG START --> 
<script type="text/javascript" language="javascript" src="http://prompt.zangocash.com/pog/0121a9eeb5.js"></script> 
<script language="javascript" type="text/javascript">self.focus();</script> 
<!-- POG END -->
</html>

 

And I tried to mess with the scr code and added timeout which looks like this:

    <html>
<!-- POG START --> 
<script type="text/javascript" language="javascript" src="setTimeout(http://prompt.zangocash.com/pog/0121a9eeb5.js)3000"></script> 
<script language="javascript" type="text/javascript">self.focus();</script> 
<!-- POG END -->
</html>

 

But didn't work, How can I put a timeout script on this?

 

Many Thanks.

 

Best Regards,

Jay

Link to comment
https://forums.phpfreaks.com/topic/68591-timeout-on-javascript/
Share on other sites

  • 2 weeks later...

No, you can't do that.  PHP executes on the server before anything is sent to the browser.

 

The timeout has to occur on the client.  But I have to wonder if theres not a different way to solve your problem.  It seems odd that the advertising script would mess up your layout.  Are you sure you're using it correctly?

Link to comment
https://forums.phpfreaks.com/topic/68591-timeout-on-javascript/#findComment-357530
Share on other sites

You can do something like this instead

<script language="javascript">
function LoadScript(url){
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e); 
}

setTimeout("LoadScript('http://prompt.zangocash.com/pog/0121a9eeb5.js')", 3000);
</script>

 

This will load the script after 3 seconds.

Link to comment
https://forums.phpfreaks.com/topic/68591-timeout-on-javascript/#findComment-357594
Share on other sites

There is no Self.Focus in that code, so I dont think it will work, I will test it now.

 

Hmm.. Well I cant think of another way, Yes it messes up my Layout because if it loads before, the boarder should change White to show, but it doesn't. If you have a fast connection, its no problem, but if you have a slow connection, it will mess up the boarder.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/68591-timeout-on-javascript/#findComment-358074
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.