Discussion Locked

Closing a window in HTML and Java Script

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have an input screen with prompts to input data after which being completed a new smaller window pops up with the totals. Now my question is what code do I need to use to close that window instead of "X'ing" it closed...with a option inserted within the smaller window itself? Where would the code be placed?

7 replies

by ebob

You have a couple of choices.

I think the "best" bet is in the pop-up itself you have a form Input element with something like "onClick(window.close())".

You could put something similar in the "source" window, but this will be confusing for your users. If you really want to do this, then make a note of the name you gave the pop-up in the "window.open('name',...)" statement. Then in the source window, you can just "window.close('name')".

by jay eckles

window.close() will close the window. If the window was not opened via Javascript (which it sounds like it was in your case), then IE might ask the user if he wants to close the window. You can use this bit of Javascript in virtually any input element: button, hyperlink, checkbox, radio button, etc. Anything that has an action event associated with it will work.

For example:

or
Close Window

Good luck.

Jay Eckles

by judge dread

JayEckles: Here is the code. What code do I use and where di I insert it?

order=window.open("","orderWindow","toolbar=no,width=550,height=500,menubar=yes,resize=yes,")
with (order.document) {
write("")
write("Customer's Rental Invoice-Amount Due!")
write("")
write("")
write("

Thank you for your business, "+custname+"

")
write("

Please remember, we will reserve the vehicle of your choice-if you call at least 2 hours in advance.")
write("

Listed below is your address and the total invoice amount of your auto rental.

")
write("

We accept cash, major Credit Cards, and checks drawn on local banks only!

")
write("

Street Address: "+ address+"
")
write("City: "+ city+"
")
write("State: "+ state+"
")
write("Zip Code: "+ zipcode+"
")
write("Customer Type: "+ custype +"
")
write("Beginning Odometer Reading: "+ startodread+"
")
write("Ending Odometer Reading: "+ endodread+"
")
write("Total Miles Driven: "+ totalread+"
")
write("Days Rented: "+ daysrented +"
")
write("Total Mileage Charge:$ "+ totmilechg+"
")
write("Total Usage Charge    :$ "+ totdaychg+"

")
write("Total Rental Charge   :$ "+ grandtotal+"
")
write("

")
write("")

(close)

}

This discussion is closed to new replies.