In VB.NET the WebBrowser component won't work the same as the actual browser [IE or Chrome] for the window.onbeforeunload event.
In the browser the event only runs when the page is going to post by a button push. But for the link to fire the javaScript function that opens a new window the event is not triggered.
In the VB.Net application with the WebBrowser component, the javaScript causes the event to trigger. This java code is called through a href link tag.
The buttons are ASP:Button for which I need the button.OnClick event to work in the coding page.
The disable button function works fine....
I already have this meta tag in
"<meta http-equiv="X-UA-Compatible" content="IE=edge" />
"
<script type="text/javascript" language="javascript" >
function popupWindow(url, windowName) {
myWindow = window.open(url, windowName, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=750, height=500, left=10, top=10");
}
function disableButton(element) {
if (!element) { return; }
element.disabled = true;
var disp = element.style.display;
element.style.display = 'none';
var trick = element.offsetHeight;
element.style.display = disp;
}
function disableButtons() {
disableButton(document.getElementById('<% =Button1.ClientID %>'))
disableButton(document.getElementById('<% =Button2.ClientID %>'))
disableButton(document.getElementById('<% =Button3.ClientID %>'))
}
window.onbeforeunload = disableButtons;
<html portion>
<asp:Button ID="Button1" runat="server" Text="Button" /><br /><br />
<asp:Button ID="Button2" runat="server" Text="Button" /><br /><br />
<asp:Button ID="Button3" runat="server" Text="Button" /><br /><br />
<a href="javascript:popupWindow('ProjLocation.aspx','ProjLocation')">ProjLocation</a><br /><br />