Guest yunkhun Posted July 15, 2009 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 Share Posted July 15, 2009 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> Link to comment Share on other sites More sharing options...
uwspstar Posted July 17, 2009 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 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
Archived
This topic is now archived and is closed to further replies.