天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

javascript showModalDialog模態對話框使用說明

1. 標準的方法
復制代碼 代碼如下:
<script type="text/Javascript">
function openWin(src, width, height, showScroll){
window.showModalDialog (src,"","location:No;status:No;help:No;dialogWidth:"+width+";dialogHeight:"+height+";scroll:"+showScroll+";");
}
</script>

例:<span style="CURSOR: pointer" onclick="openWin'http://www.jb51.NET', '500px', '400px', 'no')">點擊</span>

2. 要注意的是,Firefox并不支持該功能,它支持的語法是
復制代碼 代碼如下:
window.open
('openwin.html','newWin', 'modal=yes, width=200,height=200,resizable=no, scrollbars=no' );

3. 如何自動判斷瀏覽器
復制代碼 代碼如下:
<input type="button" value="打開對話框" onclick="showDialog('#')"/>
<SCRIPT LANGUAGE="JavaScript">
<!--
function showDialog(url)
{
if( document.all ) //IE
{
feature="dialogWidth:300px;dialogHeight:200px;status:no;help:no";
window.showModalDialog(url,null,feature);
}
else
{
//modelessDialog可以將modal換成dialog=yes
feature ="width=300,height=200,menubar=no,toolbar=no,location=no,";
feature+="scrollbars=no,status=no,modal=yes";
window.open(url,null,feature);
}
}
//-->
</SCRIPT>


4. 在IE中,模態對話框會隱藏地址欄,而在其他瀏覽器則不一定

image

image

【注意】在谷歌瀏覽器中,這個模態的效果也會失效。

5. 一般在彈出對話框的時候,我們都希望整個父頁面的背景變為一個半透明的顏色,讓用戶看到后面是不可以訪問的

 

而關閉對話框之后又希望還原

 

這是怎么做到的呢?
復制代碼 代碼如下:
///顯示某個訂單的詳細信息,通過一個模態對話框,而且屏幕會變顏色
function ShowOrderDetails(orderId) {
var url = "details.ASPx?orderID=" + orderId;
//$("body").css("filter", "Alpha(Opacity=20)");
//filter:Alpha(Opacity=50)
$("body").addClass("body1");
ShowDetailsDialog(url, "600px", "400px", "yes");
$("body").removeClass("body1");
}

另外,有一個樣式表定義
復制代碼 代碼如下:
.body1
{
background-color:#999999;
filter:Alpha(Opacity=40);
}

6. 如何在頁面之間傳遞數值
showModalDialog 傳值及刷新
(一)showModalDialog使用例子,父窗口向子窗口傳遞值,子窗口設置父窗口的值,子窗口關閉的時候返回值到父窗口.
farther.html
復制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>New Document </TITLE>
<META content="EditPlus" name="Generator">
<META content="" name="Author">
<META content="" name="Keywords">
<META content="" name="Description">
<script language="Javascript">
<!--
function openChild(){
var k = window.showModalDialog("child.html",window,"dialogWidth:335px;status:no;dialogHeight:300px");
if(k != null)
document.getElementById("txt11").value = k;
}
//-->
</script>
</HEAD>
<BODY>
<FONT face="宋體"></FONT>
<br>
傳遞到父窗口的值:<input id="txt9" type="text" value="3333333333333" name="txt9"><br>
返回的值:<input id="txt11" type="text" name="txt11"><br>
子窗口設置的值:<input id="txt10" type="text" name="txt10"><br>
<input id="Button1" onclick="openChild()" type="button" value="openChild" name="Button1">
</BODY>
</HTML>

child.html
復制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<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">
</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>
</HTML>

說明:
由于showModalDialog緩存嚴重,下面是在子窗口取消客戶端緩存的設置.也可以在服務器端取消緩存,參考:
http://adandelion.cnblogs.com/articles/252137.html
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
二)下面是關閉刷新父窗口的例子
farther.html
復制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<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 k = window.showModalDialog("child.html",window,"dialogWidth:335px;status:no;dialogHeight:300px");
if(k == 1)//判斷是否刷新
{
alert('刷新');
window.location.reload();
}
}
//-->
</script>
</HEAD>
<BODY>
<br>
傳遞到父窗口的值:<input id="txt9" type="text" value="3333333333333" NAME="txt9"><br>
<input type="button" value="openChild" onclick="openChild()" ID="Button1" NAME="Button1">
</BODY>
</HTML>

child.html
復制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<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">
</HEAD>
<BODY>
<FONT face="宋體"></FONT>
<br>
父窗口傳遞來的值:<input id="txt0" type="text" name="txt0"><br>
<input id="Button1" onclick="winClose(1)" type="button" value="關閉刷新父窗口" name="Button1">
<input id="Button2" onclick="winClose(0)" type="button" value="關閉不刷新父窗口" name="Button2">
<script language="Javascript">
<!--
var k=window.dialogArguments;
//獲得父窗口傳遞來的值
if(k!=null)
{
document.getElementById("txt0").value = k.document.getElementById("txt9").value;
}
//關閉窗口返回是否刷新的參數.
function winClose(isRefrash)
{
window.returnValue=isRefrash;
window.close();
}
//-->
</script>
</BODY>
</HTML>

說明
1.下面是取消客戶端緩存的:
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
也可以在服務器端取消緩存,參考:
http://adandelion.cnblogs.com/articles/252137.html
2.向父窗口傳遞闡述在ASP.NET中也可以是用aaa.ASPx?id=1的方式傳遞.
3.不刷新父窗口的話在父窗口中直接這樣一來設置可以.
<script>
window.showModalDialog("child.html",window,"dialogWidth:335px;status:no;dialogHeight:300px");
</script>
4.在子窗口中若要提交頁面的話要加入:,這樣就不會打開新窗口了.
<head>
<base target="_self">
</HEAD>

JavaScript技術javascript showModalDialog模態對話框使用說明,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 在线播放日韩欧美亚洲日本 | 亚洲欧美色综合影院 | 99国内精品 | 一级毛片免费播放 | 米奇在线8888在线精品视频 | 纯肉高H啪短文合集 | 亚洲1卡二卡3卡4卡新区在线 | 亚洲spank男男实践网站 | 亚洲第一成年网站视频 | 最近韩国HD免费观看国语 | 中文字幕人成人乱码亚洲影视 | 色橹橹欧美在线观看视频高清 | 永久精品免费影院在线观看网站 | 性生大片免费看 | 国产成人精品久久一区二区三区 | 亚洲精品综合在线影院 | 99久久精品国产交换 | 国产精品久久久久久人妻精品蜜桃 | 色尼玛亚洲 | 久久秋霞理论电影 | 日本zljzljzlj精品 | 港台三级大全 | 野花日本大全免费高清完整版 | 精品一区二区免费视频蜜桃网 | 在线 国产 欧美 专区 | 国产午夜在线精品三级a午夜电影 | 女子初尝黑人巨嗷嗷叫 | 国产精品免费大片一区二区 | 久久这里只有精品国产精品99 | 国产女合集小岁9三部 | 国拍在线精品视频免费观看 | 校花被扒衣吸乳羞羞漫画 | 久久这里只精品热在线99 | 国产色婷婷亚洲99精品 | 在线天天看片免费视频观看 | 国产成人精品免费视频大全办公室 | 国产精品成人免费观看 | 在线高清无码欧美久章草 | 97资源总站(中文字幕) | 天天久久影视色香综合网 | 99久久国产宗和精品1上映 |