mboehler3 Posted August 27, 2010 Share Posted August 27, 2010 I have a javascript function that I would like to delay 10-20 seconds after the page loads. I've been looking around for a solution and I thought I found one, but it's not working correctly. Here is my code: <script type="text/javascript"> $(document).ready(function tbox() { tb_show("1-Click", "/product/1-click.asp?KeepThis=true&TB_iframe=true&height=600&width=800", ""); }); window.setTimeout(tbox, 100); </script> I'm a novice with javascript at best. Is there something that I'm missing from this code? From everything I've found I thought this would work, but I must be missing something.Thanks in advance for any help. Link to comment Share on other sites More sharing options...
jeffman Posted August 27, 2010 Share Posted August 27, 2010 What if you declared the function outside the jQuery statement? Do you even want the jQuery statement? Link to comment Share on other sites More sharing options...
jeffman Posted August 27, 2010 Share Posted August 27, 2010 Wait. I see now. You want the timeout to start clicking only after the document is ready. I think you'll need to bind the setTimeout statement to the "ready event." Or cheat and put your script immediately before the closing </html> tag. Should have the same effect.BTW, how long do you think 100 milliseconds really is? Maybe that's a typo? Link to comment Share on other sites More sharing options...
mboehler3 Posted August 27, 2010 Author Share Posted August 27, 2010 Wait. I see now. You want the timeout to start clicking only after the document is ready. I think you'll need to bind the setTimeout statement to the "ready event." Or cheat and put your script immediately before the closing </html> tag. Should have the same effect.BTW, how long do you think 100 milliseconds really is? Maybe that's a typo?So would it be something like this?<script type="text/javascript"> $(document).ready(function tbox() { tb_show("1-Click", "/product/1-click.asp?KeepThis=true&TB_iframe=true&height=600&width=800", ""); }); window.setTimeout(ready(function tbox), 10000); </script> Link to comment Share on other sites More sharing options...
ShadowMage Posted August 27, 2010 Share Posted August 27, 2010 Or you could skip all that jQuery mumbo-jumbo and just do something like this: <script type="text/javascript">function tbox() { tb_show("1-Click", "/product/1-click.asp?KeepThis=true&TB_iframe=true&height=600&width=800", "");}window.onload = function() { window.setTimeout(tbox, 10000); //The wait value is in milliseconds so it should be 10000 for 10 secs}</script> Link to comment Share on other sites More sharing options...
thescientist Posted August 27, 2010 Share Posted August 27, 2010 mumbo jumbo Link to comment Share on other sites More sharing options...
mboehler3 Posted August 27, 2010 Author Share Posted August 27, 2010 Or you could skip all that jQuery mumbo-jumbo and just do something like this:<script type="text/javascript">function tbox() { tb_show("1-Click", "/product/1-click.asp?KeepThis=true&TB_iframe=true&height=600&width=800", "");}window.onload = function() { window.setTimeout(tbox, 10000); //The wait value is in milliseconds so it should be 10000 for 10 secs}</script> Awesome, thanks a lot. That's perfect. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.