You need to sign in to do that
Don't have an account?
kishore64
how to stop java script execution while clicking on command button
Hi folks,
I have a requirement like,I have a command button and if any one is clicking on this,we are redirceting to another page but when ever the user is closing the same tab or browser,we are throwing an error message through JavaScript(window.onbeforeunload event) but here the problem is,if am clicking on the command button this script is executing i.e, this error message is coming and i want to stop script execution on clicking on command button.
Please help me out!!!!!
I have a requirement like,I have a command button and if any one is clicking on this,we are redirceting to another page but when ever the user is closing the same tab or browser,we are throwing an error message through JavaScript(window.onbeforeunload event) but here the problem is,if am clicking on the command button this script is executing i.e, this error message is coming and i want to stop script execution on clicking on command button.
Please help me out!!!!!
onclick="return true;"
If this does not work then please share your code. It will help answering then.
Thanks
Shashikant
As you suggested i added onclick attribute in the command button but it's not working.please find the below code......
Please define javascript before apex:form as suggested below.
Visualforce Page:
<apex:page controller="logincntrlr" showHeader="false">
<script>
var back = false;
back = true;
window.onbeforeunload = function (e) {
if(back == true){
logCheck();
return "Are you sure to exit?";
}
else
return null;
}
</script>
<apex:form id="frm" >
<apex:actionFunction name="logCheck" action="{!logoutcheck}" reRender="frm"/>
<apex:pageMessages >
</apex:pageMessages>
<body>
<center><p><apex:commandButton value="Continue to Login" action="{!continuetologin}"/></p></center>
</body>
</html>
</apex:form>
</apex:page>
Thanks,
Gaurav