You need to sign in to do that
Don't have an account?
Amphitrite
onbeforeunload conditional? [prevent from running if commandbutton is clicked.
This script code triggers the unload actionfunction appropriately. However, I need it to not trigger if the saveClose or saveNext command buttons are hit. Any suggestions?
<script>
window.onbeforeunload = unloadPage;
function unloadPage(){unload();}
</script>
<apex:actionFunction name="unload" action="{!unload}" rerender="MyPage" />
<apex:commandButton value="Save and Close" action="{!saveClose}"/>
<apex:commandButton value="Save and Next" action="{!saveNext}"/>
Here is solution.
<script LANGUAGE="JavaScript1.2" TYPE="text/javascript">
var allowX=true;
function unloadpage(){
if(allowX){
unload();
}
else{
}
return null;
}
function setBunload(on){
window.onbeforeunload = unloadpage;
}
setBunload(true);
function clearX()
{
allowX = false;
}
</script>