Page 1 of 1

Pop-Up Window Question

Posted: Tue Feb 07, 2006 10:14 am
by icesolid
I have a button on my site that pops-up a new window that has contents to be printed.

I was just wondering if I could make that same button also refresh the page it is on after the window is popped up?

Here is my code:

Code: Select all

<input type="button" value="Print Tickets NOW" onclick="window.printtickets('printtickets.php?inspector_code=004');return false;">
I tried this code below but it did not work, but it shows how I am trying to get that button to do two different actions at the same time, is it possible?

Code: Select all

<input type="button" value="Print Tickets NOW" onclick="window.printtickets('printtickets.php?inspector_code=004');return false; history.go();">
I was also wondering if changing the button type from "button" to "submit" and making the submit action a refresh back to the same page, but I think the pop-up window would then go to the background, right?

Posted: Tue Feb 07, 2006 10:18 am
by Weirdan
change the order of 'return false;' and 'history.go()'. The way you have it history.go() never executed.

Fixed

Posted: Tue Feb 07, 2006 10:28 am
by icesolid
I played with some code and I changed my code in the headers to this:

Code: Select all

<script type="text/javascript">
<!--
function printtickets(url) {
    h = '600';
    w = '550';  

    window.open(url,'Title','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,top='+Math.floor(screen.height/2-h/2)+',left='+Math.floor(screen.width/2-w/2)+',resizable=0,width='+w+',height='+h);

    // ADDED CODE BELOW
    window.location.reload(false);
}
//-->
</script>
And I kept my submit code as this and it worked!

Code: Select all

<input type="button" value="Print Tickets NOW" onclick="window.printtickets('inspector.php?inspector_code=004');return false;" class="redButtons">
Thank you for your suggestion Weirdan!