Pop-Up Window Question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Pop-Up Window Question

Post 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?
Last edited by icesolid on Tue Feb 07, 2006 10:30 am, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

change the order of 'return false;' and 'history.go()'. The way you have it history.go() never executed.
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Fixed

Post 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!
Post Reply