2012. 9. 4. 16:20ㆍ99. 정리전 - IT/11. Java
■ X 닫기버튼 막기
function closeWindow() {
event.returnValue = "창을 닫으시겠습니까?";
}
</script>
<body onbeforeunload="closeWindow();">
■ 부모창에서 자식창으로 값 전달
<script language="javascript" type="text/javascript">
// <!CDATA[
function openDialog() {
var myArr = new Array();
myArr["arr"] = "꼴복이";
myArr["arr2"] = "똘복이";
showModalDialog("child.htm", myArr, "dialogHeight=320px;
dialogWidth=280px;scroll=no; status=yes; help=no; center=yes");
}
// ]]>
</script>
<body>
<form id="form" action="">
<input type="button" value="클릭" onclick="javascript
</form>
</body>
<script language="javascript" type="text/javascript">
// <!CDATA[
var arr_1 = window.dialogArguments["arr"];
var arr_2 = window.dialogArguments["arr2"];
var str = '부모창에서 넘어온 arr값 : ' + arr_1 + '<br />';
str += '부모창에서 넘어온 arr2값 : ' + arr_2 + '<br />';
document.write(str);
// ]]>
</script>
■ 자식창에서 부모창으로 값 전달
<!DOCTYPE html ......... 생략>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
// <!CDATA[
function openDialog() {
popupObj = showModalDialog("child.htm", self, "dialogHeight=320px;
dialogWidth=280px; scroll=no; status=yes; help=no; center=yes");
}
// ]]>
</script>
</head>
<body>
<form id="frm" action="">
<input type="button" value="클릭" onclick="javascript
<input type="text" id="parentTxt" />
</form>
</body>
</html>
var opener = window.dialogArguments;
function inputClose() {
var test = document.getElementById('childTxt').value;
opener.document.all.tags("input")[1].value = test;
self.close();
}
-----------------------------------------------------------------------
<input type="text" value="" id="childTxt" />
<input type="button" value="close" onclick="javascript
출처 : http://blog.naver.com/alfustnals?Redirect=Log&logNo=140143244066