javascript - Confirm box cancel function does the same thing as OK -
i tell me why cancel button redirects me youtube instead of cancelling out operation.
function link(){ var r = confirm("are leaving?"); if (r = true) { a.link("http://www.youtube.com");} else { return true;} } <a href="http://www.youtube.com" onclick="link()">youtube</a>
because omission of 1 equal sign, set r true here:
if (r = true) { just change to:
if (r == true) { or
if (r === true) { or to
if (r) {
Comments
Post a Comment