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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script should not popup when a form is submitted

Status
Not open for further replies.

berkshirea

Technical User
Mar 22, 2009
97
GB
hi guys, i have a script here that pops-up when a visitor is to browse away from it, which is working ok. but the moment a form is submitted, it still pops-up, which i don't want.

how can i stop this popping up when 'Submit' button is clicked?

Code:
<body>
<script>
function goodbye(e) {
	if(!e) e = window.event;
	//e.cancelBubble is supported by IE - this will kill the bubbling process.
	e.cancelBubble = true;
	e.returnValue = 'Please comment on this draft.'; //This is displayed on the dialog

	//e.stopPropagation works in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
}
window.onbeforeunload=goodbye;
</script>

<form id="form1" name="form1" method="post" action="test.aspx">
  <label>
  <input type="text" name="textfield" />
  </label>
  <input type="submit" name="Submit" value="Submit" />
</form>
</body>

thanks for any help.
 
Hi

I would try this :
Code:
[b]<form[/b] [maroon]id[/maroon][teal]=[/teal][green][i]"form1"[/i][/green] [maroon]name[/maroon][teal]=[/teal][green][i]"form1"[/i][/green] [maroon]method[/maroon][teal]=[/teal][green][i]"post"[/i][/green] [maroon]action[/maroon][teal]=[/teal][green][i]"test.aspx"[/i][/green] [highlight][maroon]onsubmit[/maroon][teal]=[/teal][green][i]"window.onbeforeunload=undefined"[/i][/green][/highlight][b]>[/b]
( Actually I lied. I would remove that annoying dialog. )


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top