Parent.hmtl
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<голова>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> родительское окно </title>
<script type = "text/javascript">
window.onload = function () {
var btn = document.getElementById ("btn");
btn.onclick = function () {
var obj = {
Тест: «Чжан Сан переходит в детское окно»,
Win: окно
};
var returnvalue = window.showmodaldialog ("child.html", obj, "dialogleft: 100px; dialogtop: 100px; dialogwidth: 400px; dialogheight: 300px; rel -lizable: yes");
if (returnvalue! = null) {
document.getElementbyId ("content"). innerHtml = returnValue;
}
};
}
</script>
</head>
<тело>
<div id = "content" style = "margin: 50px; ширина: 100px; высота: 150px; граница: 5px solid #0000ff;"> </div>
<input type = "кнопка" id = "btn" value = "opup subwindow">
</body>
</html>
Ребенок.html
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<голова>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Подгновое окно </title>
<script type = "text/javascript">
window.onload = function () {
// Получить параметр Pass URL
var args = window.dialogarguments;
var win = args.win; // председательствующий объект окна
var content = document.getElementbyId ("content");
content.value = args.test;
var btn = document.getElementById ("btn");
btn.onclick = function () {
// Модальное диалоговое окно будет иметь значение
window.returnValue = content.value;
window.close ();
}
}
</script>
</head>
<тело>
<input type = "text" id = "content"> <input type = "кнопка" id = "btn" value = "vade value to parent window">
</body>
</html