How to use clickonce for html button [closed]
I am trying to use this javascript for clcik once but I m unable to get results can anyone please tell me whats wrong with this script
function clickOnce(btn, msg) {
// Test if we are doing a validation
//if (typeof (Page_ClientValidate) == 'function') {
// if we are doing a validation, return if it's false
//if (Page_ClientValidate() == false) { return false; }
//}
// Ensure that the button is not of type "submit"
if (btn.getAttribute('type') == 'button') {
// The msg attibute is absolutely optional
// msg will be the text of the button while it's disabled
if (!msg || (msg = 'undefined')) { msg = 'Loading...'; }
btn.value = msg;
// The magic :D
btn.disabled = true;
}
return true;
}
Can anyone tell me whats wrong with this script
Your second if
clause does not check if msg
is undefined
, but assigns undefined
to it. Therefore, the final value of msg
will always be Loading...
.
Also, null
and undefined
are already taken care of by the !
operator, so you only need:
if (!msg) {
msg = "Loading...";
}
btn.value = msg;
Or maybe, if you want to take advantage of the short-circuiting nature of the ||
operator:
btn.value = msg || "Loading...";
have you debugged this with developer tools in the browser? it acts as though the function is not finishing its process like you think it is, so the return true is never hit, and there is an error being thrown somewhere.
精彩评论