开发者

How to use clickonce for html button [closed]

It's difficult to tell what is being开发者_开发百科 asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜