JS模态窗口

来源:互联网 发布:pi实时数据库 编辑:程序博客网 时间:2024/05/16 15:46

父页面 弹出 窗口:

function showTDYT()
{
   //打开模态子窗体,并获取返回值
   var result=showModalDialog('土地储备-用途.htm','这里随便命名','dialogWidth:320px;dialogHeight:530px;center:yes;help:no;resizable:no;status:no');
   $("#txtYongTu").val(result);
}

子页面的方法和返回值:

 function tc() //参数分别为id,name和password
{
   var getCC=$("#cc").text(); //获取想要的值
   window.returnValue= getCC;   //返回 结果   
   window.close();          //firefox不支持window.close()
}

代码:

<script language="javascript" type="text/javascript">
function InsertTag(tagname)
{
if(window.opener.document.getElementById("Editor_Edit_Advanced_txbTag").value == '')
{
window.opener.document.getElementById(
"Editor_Edit_Advanced_txbTag").value += tagname;
}
else
{
window.opener.document.getElementById(
"Editor_Edit_Advanced_txbTag").value += "," + tagname;
}

}
</script>

<a onclick="InsertTag('CSS')" href="#">CSS</a>

 1、使用脚本关闭窗口时防止出现确认框

在做网页的时候,有时候在完成某个功能的时候需要关闭当前窗口,但现在的新版的浏览器中在使用脚本 window.close() 方法来关闭窗口时,总是会出现一个确认框,这带来非

常不好的体验。最近在网上又找到了一种新方法,这个可以防止出现确认框:
window.opener = null;
window.open("", "_self");
window.close();

2、防止 showModalDialog 方法打开网页时总是显示缓存
在使用 showModalDialog 方法显示网页的时候,如果不做什么设置,基本每次都是显示一个缓存的页面,这在开发的时候是个很麻烦的事,如果不让它显示缓存呢?其实只要在网

页的 区加上下面一段代码就可以了:
<meta http-equiv="cache-control" content="no-cache, must-revalidate">

1、使用脚本关闭窗口时防止出现确认框

在做网页的时候,有时候在完成某个功能的时候需要关闭当前窗口,但现在的新版的浏览器中在使用脚本 window.close() 方法来关闭窗口时,总是会出现一个确认框,这带来非

常不好的体验。最近在网上又找到了一种新方法,这个可以防止出现确认框:
window.opener = null;
window.open("", "_self");
window.close();

2、防止 showModalDialog 方法打开网页时总是显示缓存
在使用 showModalDialog 方法显示网页的时候,如果不做什么设置,基本每次都是显示一个缓存的页面,这在开发的时候是个很麻烦的事,如果不让它显示缓存呢?其实只要在网

页的 区加上下面一段代码就可以了:
<meta http-equiv="cache-control" content="no-cache, must-revalidate">

原创粉丝点击