HighDots Forums  

onBeforeUnload doesn't work quite as I want it to

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss onBeforeUnload doesn't work quite as I want it to in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Richard \(MrBonus\)
 
Posts: n/a

Default onBeforeUnload doesn't work quite as I want it to - 09-02-2004 , 03:18 PM






the code is taken from my asp.net page.

Hi, im trying to make my page postback before the it unloads, i've tried a
lot of stuff, and finally I made something that worked, the problem is the
alert in the code -- alert('TittyX'); --. If I remove it, then it doesn't
work, well the method runs fine, but I can't catch the --
theform.submit(); --.

Another weird thing, is I can only catch the event in the Page_Load event on
the server, which is weird, but I can live with that, what I can't live with
is the alert.

Anyone who knows either another solution, or can tell me what I should do to
make it work?


<body MS_POSITIONING="GridLayout" onbeforeunload="__doUnloadPostBack()"
language="javascript">
<script language="javascript">
<!--
function __doUnloadPostBack() {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape")
Quote:
-1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.submit();
alert('TittyX');
}
// -->
</script>

<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 184px; POSITION:
absolute; TOP: 120px" runat="server" Text="Button"></asp:Button>
</form>
</body>


Richard




Reply With Quote
Reply




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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.