Current location: Hot Scripts Forums » General Web Coding » JavaScript » Closing a window onclick !


Closing a window onclick !

Reply
  #1 (permalink)  
Old 07-07-06, 07:11 AM
n3wb!e's Avatar
n3wb!e n3wb!e is offline
Wannabe Coder
 
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
Closing a window onclick !

hi everyone, i just want to know is there any method to close a window after clicking on the submit button ? i have used
Code:
<input type="submit" name="submit" value="submit" onclick="window.close()">
i want something like this.. whenever the user clicks on submit button, it should submit the form values(textboxes) and then close the form. is that possible ?

i hv something like this.
Code:
<html>
<body>
<form method="post" action="insert.php">
<input type="text" name="name">
<input type="text" name="age">
<input type="submit" value="submit" name="submit" onclick="window.close()">
</form>
</body>
</html>
in 'insert.php' i m inserting the values which r passed by this form. i dont want the user to use the 'previous' button of his webbrowser and submit again.. can anything be done ? plz help ! thanks in advance..
Reply With Quote
  #2 (permalink)  
Old 07-07-06, 03:09 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Put this in the head tag:
Code:
<script>
function closeOnSubmit(){
 window.close()
}
document.onunload=closeOnSubmit
The onunload event fires when a form is submitted, either via the <input type="submit"> control or by calling form.submit() directly.
Note that if you try to close a window which wasn't opened by JS, the browser will show a confirm box.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old 07-10-06, 06:54 AM
n3wb!e's Avatar
n3wb!e n3wb!e is offline
Wannabe Coder
 
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
thanks.. sorry for replying so late.. plz dont mind.. thanks again.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a link in a window in another window, which is already open. andr345 JavaScript 1 06-15-06 03:25 AM
popup brower pai Flash & ActionScript 3 05-17-06 09:28 PM
closing browser's window sharad PHP 3 08-13-05 01:30 PM
Modal Window over a modal window goog JavaScript 1 01-29-05 11:58 AM
[Help] Javascript pop up window with background color empty.container JavaScript 1 01-13-05 03:11 AM


All times are GMT -5. The time now is 11:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.