www.webdeveloper.com
Results 1 to 3 of 3

Thread: Two functions in one setTimeout?

  1. #1
    Join Date
    Nov 2005
    Posts
    18

    Two functions in one setTimeout?

    I have this:

    Code:
    <script type="text/javascript">
    var changeIt, print_div;
    changeIt = function()
    { print_div = document.getElementById("sec_content").innerHTML;
    newwindow=window.open( 'targetpage.html', target="_blank" );
    setTimeout('newwindow.document.getElementById("print_content").innerHTML=print_div',1000)
    };
    </script>
    but I want to also include this within the setTimeout: newwindow.document.getElementById("menu_box_cont").style.display="none"

    how can I do that? I'll appreciate any help.

  2. #2
    Join Date
    Jun 2007
    Posts
    104
    Why not create a function that does both actions, then call that in the setTimeout function?

    Code:
    function doBoth(){
    	newwindow.document.getElementById("print_content").innerHTML=print_div;
    	newwindow.document.getElementById("menu_box_cont").style.display="none";
    }
    setTimeout(doBoth,1000);
    Note that I didn't account for scope in this example, so it probably won't work for you without a little tweaking. Hope that helps.

  3. #3
    Join Date
    Nov 2005
    Posts
    18
    stevea, will try that, thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles