window.showModalDialog()、confirm()方法使用

window.showModalDialog()、confirm()方法使用

运行描述:在A页单击按钮弹出对话框B,选择要选择的栏目,弹出确认信息。确定后对话框B自动关闭,其所选择的栏目值传到A页相应的文本框内。代码如下

A.htm

< script >
function  openwin(){
var  value  =  window.showModalDialog( " b.htm " ,window, " dialogWidth:370px;help:no;resizable:no;status:no;scroll:no " );
document.form1.a.value 
=  value;
}
</ script >
选择栏目:
< href ="#"  onClick ="javascript:openwin();" > click </ a >
< form  name ="form1" >
< input  name ="a"  type ="txt" >
</ form >

B.htm

< script >
function  returnAll(str){
   
if (confirm( " 是否选择' " + str + " ' " )){
      window.returnValue
= "" + str + "" ;
      window.close();
   }
}
</ script >
< form  name ="form1" >
< href ="#"  onClick ="javascript:returnAll(this.innerText);"  id ="a" > a </ a >
< href ="#"  onClick ="javascript:returnAll(this.innerText);"  id ="b" > b </ a >
< href ="#"  onClick ="javascript:returnAll(this.innerText);"  id ="c" > c </ a >
</ form >

window.opener.location.reload();
当A页面弹出B页面时,在B页面如果调用这句js代码,则会刷新A页面。

你可能感兴趣的:(window.showModalDialog()、confirm()方法使用)