Javascript 单击“确认”框上的“取消”时,页面应刷新
我正在调用两种方法onclick,第一种是停止多次单击按钮,第二种是显示确认框。一旦用户单击“取消”,用户将无法再次保存它。我正在寻找解决方案来区分这两种方法点击Javascript 单击“确认”框上的“取消”时,页面应刷新,javascript,visualforce,confirm,Javascript,Visualforce,Confirm,我正在调用两种方法onclick,第一种是停止多次单击按钮,第二种是显示确认框。一旦用户单击“取消”,用户将无法再次保存它。我正在寻找解决方案来区分这两种方法点击 return confirm('Changing the protocol will reset the project Team members'); } 函数showProtocolEditWarning(){ if(projectId和PRA协议){ var newProject=docume
return confirm('Changing the protocol will reset the project Team members');
}
函数showProtocolEditWarning(){
if(projectId和PRA协议){
var newProject=document.querySelector('input[id$=“inputFieldPraProject\u lkid”]”)。值;
var protocolidement=document.querySelector('select[id$=“protocolidelist”]”);
var newProtocol=protocolidement.options[protocolidement.selectedIndex].value;
if(praProject.substring(0,15)!=newProject.substring(0,15)| | praProtocol!=newProtocol){
返回确认(“更改协议将重置项目团队成员”);
//window.location.reload();
}
}
返回true;
}
您应该检查用户单击的内容,而不是返回确认(…)
,如果用户单击了取消,请使用location.reload()
重新加载页面:
函数confirmMessage(){
如果(确认('Your confirmation msg'){//,即如果用户按下ok
//处理这个
}
否则{//,即用户按了取消
location.reload();
}
}
使用location.reload()
刷新页面。您有什么问题?
<apex:commandButton onclick=" this.onclick=function(){return false;}; return showProtocolEditWarning();" action="{!save}" value="Save" id="commandButtonSave"/>
function showProtocolEditWarning(){
if(projectId && praProtocol){
var newProject = document.querySelector('input[id$="inputFieldPraProject_lkid"]').value;
var protocolIdElement = document.querySelector('select[id$="protocolIdList"]');
var newProtocol = protocolIdElement.options[protocolIdElement.selectedIndex].value;
if(praProject.substring(0,15) != newProject.substring(0,15) || praProtocol != newProtocol){
return confirm('Changing the protocol will reset the project Team members');
//window.location.reload() ;
}
}
return true;
}