替换:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script>
window.confirm = abc;
function abc(v)
{
alert(v);
}
</script>
</head><body>
<button onclick=confirm('yyy')>xx</button>
</body>
</html>或者你贴一下你的代码,大家讨论
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script>
window.confirm = abc;
function abc(v)
{
alert(v);
}
</script>
</head><body>
<button onclick=confirm('yyy')>xx</button>
</body>
</html>或者你贴一下你的代码,大家讨论
-----------------------------------------------------------//message:消息
//callBack:代码字符串,可以是普通代码,也可以是函数
window.confirm=function ShowConfirm(message,callBack)
{
///这里是显示一个框的代码,一般是使用div做的
///这个框里面有两个按钮,点击后分别返回true和false
///这里还缺乏一部分代码:就是让javascript停止执行的代码,不过好像没有找到
}所以现在最重要的是知道javascript的confirm执行原理(原型),这样就可以完整的重写这个函数。各位XDJM,看看哪里可以找到啊?
----------------------------------------------------------
var opacity=0;
//显示背景div,使整个界面模糊
function ShowBack()
{
document.body.innerHTML += '<div id="divBack" style="Z-INDEX:0;background:white;position:absolute;filter:alpha(opacity=60)" > </div>';
div=document.getElementById("divBack");
div.style.left = 0;
div.style.top = 0;
div.style.width = document.body.offsetWidth;
div.style.height = document.body.offsetHeight;
}
var confirmCallBack=null;
//显示对话框的div,上面有两个按钮“是”和“否”
window.confirm=function ShowConfirm(message,callBack)
{
confirmCallBack=callBack;
ShowBack();
document.body.innerHTML += '<div id="divBox" style="Z-INDEX:10;background:white;position:absolute;"><table border="0" width="100%"><tr><td align="center">'+message+'</td></tr><tr><td align="center"><input type="button" value="确 定" onclick="CloseConfirm(true)"> <input type="button" value="取 消" onclick="CloseConfirm(false)"></td></tr></table></div>';
div=document.getElementById("divBox");
div.style.left = (document.body.offsetWidth-300)/2;
div.style.top = (document.body.offsetHeight-150)/2;
div.style.width = "300px";
div.style.height = "150px";
return false;
}function CloseConfirm(isok)
{
document.getElementById("divBox").removeNode(true);
document.getElementById("divBack").removeNode(true);
if(isok && confirmCallBack!=null)
eval(confirmCallBack);
return isok;
}
------------------------------------------
window.confirm=function ShowConfirm(message,callBack)
{
confirmCallBack=callBack;
ShowBack();
document.body.innerHTML += '<div id="divBox" style="Z-INDEX:10;background:white;position:absolute;"><table border="0" width="100%"><tr><td align="center">'+message+'</td></tr><tr><td align="center"><input type="button" value="确 定" onclick="CloseConfirm(true)"> <input type="button" value="取 消" onclick="CloseConfirm(false)"></td></tr></table></div>';
div=document.getElementById("divBox");
div.style.left = (document.body.offsetWidth-300)/2;
div.style.top = (document.body.offsetHeight-150)/2;
div.style.width = "300px";
div.style.height = "150px";
}
运行showModalDialog