I'm calling a Javascript window.prompt()
and prompting the user to submit a variable which I compare to another variable (a very basic password protection). The function works great, however, if you click "cancel"
on the prompt()
window, the function does not simply terminate, but rather compares the variable to an empty string, (which the user opted not to submit by pressing "cancel" instead) resulting in the function continuing to the else{ }
portion.
My question is, how do I terminate the function upon pressing cancel? I just need to know how to target the cancel button.
Usually I would just call a .stop()
on the click()
of a button, but I don't know how to target the prompt-window's cancel button.
question from:
https://stackoverflow.com/questions/12864582/javascript-prompt-cancel-button-to-terminate-the-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…