1、不能使用window.parent
Window.parent是用來在frame中進行操作的,在對話框中不能用來操作父窗口對象
2、正確的做法
調用modaldialog時通過傳參數的方式操作
例:
需求
父窗口頁面為a.Html 子窗口頁面為b.html。a.html中有文本框id為test1,在打開的對話框中點擊按鈕,將a.html的文本框值改為“子窗口值”。
實現
打開對話框時把test1作為參數傳給子窗口,在子窗口中獲取參數,將參數對象(即a.html中傳過來的text對象)的value屬性值設置為“子窗口值”
注重:這里只能傳id,不能傳name
a.html代碼如下
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>a.html</title>
</head>
<body>
<input type=text id=test1 value=''>
<input type=button value=" OK " onclick='window.showModalDialog("b.html", test1)'>
</body>
</html>
b.html代碼如下
<html>
<head>
新聞熱點
疑難解答