首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

怎么实现confirm同样的效果

2012-09-01 
如何实现confirm同样的效果?JScript codeif (confirm(此操作不可逆转,你确定进行此操作?)) {//....操作

如何实现confirm同样的效果?

JScript code
if (confirm("此操作不可逆转,你确定进行此操作?")) {//....操作代码}

就是我想了解下confirm是怎么做到这点的:如果不去点击“确定”或者“取消”按钮时,它是不去执行 操作代码的内容的。
谢谢了,很想知道原因。

[解决办法]
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>test</title><style>#all{    width:270px;    height:80px;    background:#999;    position:absolute;    z-index:1000;    display:none;    border:1px solid red;}#message{    width:100%;    height:40px;}#ok{    margin-left:80px;}</style><script src="jquery-1.3.2.js"></script><script>$(function(){    $("#btn").click(function(){        $("#all").show();    });    $("#ok").click(function(){        $("#all").hide();    });    $("#cancle").click(function(){        $("#all").hide();        return;    });});</script></head><body><input type="button" value="测试" id="btn" onclick="test()" /><div id="all">    <div id="message">此操作不可逆转,你确定进行此操作?</div>    <input type="button" value="确定" id="ok" />    <input type="button" value="取消" id="cancle" /></div></body></html> 

热点排行