Tuesday, February 17, 2009

JavaScript - Confirm OK Cancel - Yes No

just cam across a post, brilliant way to change the confirm box from ok / cancel to yes / no.

Well it doesn't work in Mozilla though, it returns ok / cancel only

http://www.delphifaq.com/faq/javascript/f1172.shtml

<script language=javascript>

/*@cc_on @*/
/*@if (@_win32 && @_jscript_version>=5)

function window.confirm(str)
{
execScript('n = msgbox("'+str+'","4132")', "vbscript");
return(n == 6);
}

@end @*/
var r = confirm("Can you do it?");
alert(r);
</script>

2 comments:

  1. will it work in all browsers, and there any way to change vbscript as Inventory

    ReplyDelete
  2. I have tested it in IE and Mozilla. It worked on IE only.

    ReplyDelete