怎样把这个WaitTime赋值为js传递值呢?
发布网友
发布时间:2022-05-02 05:06
我来回答
共1个回答
热心网友
时间:2022-06-28 12:05
按照你要求弄好了,不过这分不至于给这么点吧,还不如别设置了好点。好了,两个页的代码你拿过去都复制粘贴看看!!
具体代码如下:
1.html
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript">
<!--
function openChild(){
var aa = document.getElementById("txtaa").value;
var k = window.showModalDialog("2.html?time="+aa,window,"dialogWidth:335px;status:no;dialogHeight:300px");
if(k != null)
document.getElementById("txt11").value = k;
}
//-->
</script>
</HEAD>
<BODY>
<br>传递到父窗口的值:<input id="txt9" type="text" value="500">
<br>传递到子窗口的关闭时间:<input id="txtaa" type="text" value=""><br>
返回的值:<input id="txt11" type="text"><br>
子窗口设置的值:<input id="txt10" type="text"><br>
<input type ="button" value="openChild" onclick="openChild()">
</BODY>
</HTML>
2.html
<HTML>
<HEAD>
<TITLE>New Document </TITLE>
<META content="EditPlus" name="Generator">
<META content="" name="Author">
<META content="" name="Keywords">
<META content="" name="Description">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<script language="javascript">
<!--
var string = window.location.href;
var settime = string.split("=");
var WaitTime = settime[1]; //等待的时间,单位秒
function WaitDo(){
if(WaitTime > 0){
putOutMsg.innerHTML = "本提示"+ WaitTime +"秒后自动关闭";
WaitTime --;
setTimeout("WaitDo()",1000);
}
else
{
window.opener=null; window.open("",'_self',""); window.close();
}
}
//-->
</script>
</HEAD>
<BODY>
<FONT face="宋体"></FONT><br>
父窗口传递来的值:<input id="txt0" type="text" name="txt0"><br>
输入要设置父窗口的值:<input id="txt1" type="text" name="txt1"><input id="Button1" onclick="setFather()" type="button" value="设置父窗口的值" name="Button1"><br>
输入返回的值:<input id="txt2" type="text" name="txt2"><input id="Button2" onclick="retrunValue()" type="button" value="关闭切返回值" name="Button2">
<input id="Button3" onclick="" type="button" value="关闭刷新父窗口" name="Button3">
<script language="javascript">
<!--
var k=window.dialogArguments;
//获得父窗口传递来的值
if(k!=null)
{
document.getElementById("txt0").value = k.document.getElementById("txt9").value;
}
//设置父窗口的值
function setFather()
{
k.document.getElementById("txt10").value = document.getElementById("txt1").value
}
//设置返回到父窗口的值
function retrunValue()
{
var s = document.getElementById("txt2").value;
window.returnValue=s;
window.close();
}
//-->
</script>
<body onLoad="WaitDo();" style="margin:20px;">
<span id="putOutMsg" class="OpenFont"></span>
</BODY>
</HTML>