模拟的Alert("conent:内容;title:标题")
1.htm和b.htm放在同一目录<!--1.htm-->
<script language="JavaScript">
<!--
function Alert(strText){
var pWin=window.showModalDialog("b.htm",strText,"dialogHeight:116px; dialogWidth:232px; help: No; resizable: no; status: No; scroll:no; dialogTop:"+(screen.height-116)/2+"px; dialogLeft:"+(screen.width-232)/2+"px;");
}
Alert("content:警告内容部分?;title:警告标题;");
//-->
</script> -------------------------------------------------
<!--b.htm-->
<html>
<head>
<style type="text/css">
body{ }
td,input{ font-size:12px}
</style>
<script language="JavaScript">
<!-- var str = window.dialogArguments;
var getAttribute=function(source, name)
{
var reg = new RegExp("(^|;|\\s)"+ name +"\\s*:\\s*([^;]*)(\\s|;|$)", "i");
if (reg.test(source))
return RegExp.$2.replace(/[\x0f]/g, ";").replace(/\'/g, "'"); return "";
}; function doOk(){
window.returnValue="yes";
window.close();
}
document.write('<title align="center">'+getAttribute(str,"title")+' </title>');
//-->
</script>
</head>
<body style="background-color:buttonface; margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr height="65%">
<td width="25%" align="center" valign="center"><img src="http://home.nuc.edu.cn/~chandler/images/warning.jpg" style="width:32px; height:32px"></td>
<td valign="middle">
<script language="JavaScript">
<!--
document.write(getAttribute(str,"content"));
//-->
</script>
</td>
</tr>
<tr height="35%">
<td colspan="2" align="center" valign="top">
<input type="button" id="btnOk" value=" 确定 " style="width:80px;" onclick="doOk()"> </td>
</tr>
</table>
</body>
<script language="JavaScript">
<!--
document.onclick=function (){
document.getElementById("btnOk").focus();
}
document.body.oncontextmenu=function (){
document.getElementById("btnOk").focus();
}
//-->
</script>
<html>
1.htm和b.htm放在同一目录<!--1.htm-->
<script language="JavaScript">
<!--
function Alert(strText){
var pWin=window.showModalDialog("b.htm",strText,"dialogHeight:116px; dialogWidth:232px; help: No; resizable: no; status: No; scroll:no; dialogTop:"+(screen.height-116)/2+"px; dialogLeft:"+(screen.width-232)/2+"px;");
}
Alert("content:警告内容部分?;title:警告标题;");
//-->
</script> -------------------------------------------------
<!--b.htm-->
<html>
<head>
<style type="text/css">
body{ }
td,input{ font-size:12px}
</style>
<script language="JavaScript">
<!-- var str = window.dialogArguments;
var getAttribute=function(source, name)
{
var reg = new RegExp("(^|;|\\s)"+ name +"\\s*:\\s*([^;]*)(\\s|;|$)", "i");
if (reg.test(source))
return RegExp.$2.replace(/[\x0f]/g, ";").replace(/\'/g, "'"); return "";
}; function doOk(){
window.returnValue="yes";
window.close();
}
document.write('<title align="center">'+getAttribute(str,"title")+' </title>');
//-->
</script>
</head>
<body style="background-color:buttonface; margin:0">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr height="65%">
<td width="25%" align="center" valign="center"><img src="http://home.nuc.edu.cn/~chandler/images/warning.jpg" style="width:32px; height:32px"></td>
<td valign="middle">
<script language="JavaScript">
<!--
document.write(getAttribute(str,"content"));
//-->
</script>
</td>
</tr>
<tr height="35%">
<td colspan="2" align="center" valign="top">
<input type="button" id="btnOk" value=" 确定 " style="width:80px;" onclick="doOk()"> </td>
</tr>
</table>
</body>
<script language="JavaScript">
<!--
document.onclick=function (){
document.getElementById("btnOk").focus();
}
document.body.oncontextmenu=function (){
document.getElementById("btnOk").focus();
}
//-->
</script>
<html>
execScript("msgbox '测试1',0,'测试2' ","vbscript")
</script>
感谢楼主我刚刚完成了一个很粗糙的版本
由于 HTWindow 也在同步修改
所以漏洞多多
请大家多指教demo http://hotoo.ik8.com/demo/javascript/HTAlert.html如果要模拟 confirm() 则比较困难
因为需要阻断进程(或线程)
而alert()只是一个提示
可以不需要阻断进程(或线程)