js中showModalDialog和returnValue的用法
有兩個頁麵father.html和child.html
father.html
<html>
<head>
<title>父窗體</title>
<script type="text/javascript">
$(function(){
$("#btn").click(function(){
var childValue = window.showModalDialog ('Child.html',null,"help:no;status:no;dialogWidth:900px;dialogHeight:540px");
$("#spanChildValue").append(childValue);
});
});
</script>
</head>
<body>
<input type="button" value="彈出子窗口" />
<span >子窗體返回的值是</span>
</body>
</html>
child.html
<html>
<head>
<title>子窗體</title>
<script type="text/javascript">
$(function(){
$("#btn").click(function() {
window.returnValue = "1";
window.close();
});
});
</script>
</head>
<body>
<input type="button" value="生成返回值" />
</body>
</html>
通過showModalDialog打開子窗體後,子窗體不關閉,父窗體不能做操作。
操作子窗體通過returnValue返回一個值並關閉。這個時候父窗體就拿到了這個值。
當然子窗體不僅可以返回字符串,數字,也可以是對象等。
最後更新:2017-04-02 17:51:22
上一篇:
JavaScript中typeof和instanceof的區別
下一篇:
JAVA循環體的過濾器 (continue)
Java IO: PipedInputStream
調試MVC源代碼時"[A]System.Web.WebPages.Razor.Configuration.HostSection 無法強製轉換為 ..."解決辦法
#pragma 用法
pyinotify:在 Linux 中實時監控文件係統更改
PostgreSQL 聚合函數講解 - 3 總體|樣本 方差, 標準方差
vitess中rpc兼容http請求的技巧
端口檢測工具Fport的使用
【雲計算的1024種玩法】讓ECS摻金坷垃,輕鬆打造離線下載服務器
tomcat報錯:The server does not support version 3.0
android之listview緩存圖片(緩存優化)