Guest yunkhun Posted July 15, 2009 Report Share Posted July 15, 2009 do you know why this doesn't work in chrome and safari? thanks...<html><head><script type="text/javascript">function show_confirm(){var r=confirm("Press a button");if (r==true) { document.write("You pressed OK!"); }else { document.write("You pressed Cancel!"); }}</script></head><body><input type="button" onclick="show_confirm()" value="Show a confirm box" /></body></html> Link to comment Share on other sites More sharing options...
dsonesuk Posted July 15, 2009 Report Share Posted July 15, 2009 (edited) not the best of examples, as it seems to go through a loop trying to open a new page.try this:<html><head><script type="text/javascript">function show_confirm(){var r=confirm("Press a button");var x=document.getElementById("swap");if (r==true) { //document.write("You pressed OK!"); x.innerHTML="You pressed OK!"; }else { //document.write("You pressed Cancel!"); x.innerHTML="You pressed Cancel!"; } }</script></head><body><div id="swap"><input type="button" onclick="show_confirm();" value="Show a confirm box" /></div></body></html> Edited July 15, 2009 by dsonesuk Link to comment Share on other sites More sharing options...
uwspstar Posted July 17, 2009 Report Share Posted July 17, 2009 do you know why this doesn't work in chrome and safari? thanks...<html><head><script type="text/javascript">function show_confirm(){var r=confirm("Press a button");if (r==true) { document.write("You pressed OK!"); }else { document.write("You pressed Cancel!"); }}</script></head><body><input type="button" onclick="show_confirm()" value="Show a confirm box" /></body></html> this is the example, w3school gavehttp://w3schools.com/js/tryit.asp?filename=tryjs_confirm Link to comment Share on other sites More sharing options...
dsonesuk Posted July 17, 2009 Report Share Posted July 17, 2009 I know, i visited the example page, that is why i said it was not the best of examples. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now