Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close main page using JavaScript 1

Status
Not open for further replies.

nissan240zx

Programmer
Joined
Jun 26, 2005
Messages
280
Location
US
Hello All,
Trying to do a window close thing.
the scenario is..I have a form "index.asp" which on submit comes to a thank you page "process.asp"
What I would like to do is...
When this process.asp gets loaded and is displayed, the very same time show a Alert Button kind of thing,which when clicked closes the paqe altogether.
Please help...

thanks in advance..

Nissan...

A good programmer is someone who looks both ways before crossing a one-way street. - Doug Linder
 
>...when clicked closes [green]the paqe[/green] altogether.

If "the page" is meant for the process.asp (the thank-you page), I guess you can make an onload in the thank-you page.
[tt]
window.onload=function() {
alert("You have submitted the info. Thank you!");
window.opener=self;
window.close();
}
[/tt]
If "the page" is meant for the index.asp, maybe this.
[tt]
window.onload=function() {
alert("You have submitted the info. Thank you!");
if (window.opener && !window.opener.closed) {
window.opener.close();
}
[/tt]
 
I do not know the specifics of your situation but I personally think closing someones main browser window is a bad idea. People often jump from site to site with the same browser window. If they visit a site or two then go to yours, they might want to use their browser back button or it's history to skip back to someplace they were previously and you would annoy them by closing that window.



Stamp out, eliminate and abolish redundancy!
 
So they all say and you choose to repeat their tongue...

My main business is to mention a typo in my second function, missing a closing curly bracket for the if-statement. I'm sure op can detect and correct for him/herself.

 
Tsuji,
Its super..
Worked like a charm...
Wish I could give 10 stars for all the advice and help you have done in the past few days...

Excellent...

Nissan....

A good programmer is someone who looks both ways before crossing a one-way street. - Doug Linder
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top