javascript模態表單各種用法)

來源:互聯網
上載者:User
1。開啟視窗:
var handle = window.showModalDialog(url, objects, feathers);
其中:objects可以為參數(包括數組),也可以是對象。
通常的用法 objects = {window} ,把父表單的對象共用給子表單。

2。關閉子視窗:
window.close();

3。從子表單傳參數給父表單:
window.returnVal = string;

4。清除緩衝,防止強制回應視窗頁面不更新的情況:
HTML
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Mon, 23 Jan 1978 20:52:30 GMT">
ASP
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
%>
PHP
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
JSP
response.setHeader("Pragma","No-Cache");
response.setHeader("Cache-Control","No-Cache");
response.setDateHeader("Expires", 0);

5。防止開啟新視窗(如提交表單):
<base target="_self">

6。在強制回應視窗使用F5重新整理頁面:
<base target="_self">
<body onkeydown="if (event.keyCode==116){reload.click()}">
<a id="reload" href="filename.htm" style="display:none">reload...</a>
其中:filename為視窗頁面。

7。防止強制回應視窗開啟的頁面出現cookie丟失的情況:
強制回應視窗開啟新視窗時,僅可以使用 showModalDialog(url,window,feathers); 方法,且 objects 為 window 。

8。在快顯視窗中獲得或設定主視窗的任何值:
開啟快顯視窗時用:showModalDialog(url, window, feathers)
在快顯視窗中使用 window.dialogArguments 對象(即主視窗傳遞過來的 window 對象集),即可以獲得或者設定主視窗的值。

9 子頁面關閉同時重新整理父頁面

調用方法

        父頁面:openModelWin('ChooseStyle.aspx');

        子頁面:closeWin()

指令碼:

function openModelWin(url)
{
    var obj = showModalDialog(url,'title',"dialogWidth:600px;");
   
    if(obj =='reload')
    {
        window.location.reload();
    }
}
function closeWin()
{
    window.opener = null;
   
    window.close();
    window.returnValue='reload';
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.