Javascript
window.open 후 자식창에서 자식창의 함수 실행
coding-restaurant
2021. 6. 3. 16:22
728x90
728x90
var testValue = 22;
var vWindow = window.open(vUrl);
vWindow.addEventListener("load", openNewTab(testValue, vWindow));
// 새창열기 - 팝업창 로드가 완료되면 실행
function openNewTab(testValue, vWindow) {
var test = vWindow.document.body; // 팝업창의 html 전체
if (test == null) {
//alert("아직안됨");
} else {
//alert("로드됨");
if (vWindow.cvCJSDocHandler) {
vWindow.childFunction.testFunction(testValue);
vWindow.focus();
} else setTimeout(function () {
openNewTab(vRefID, vWindow);
}, 500);
}
}
<html>
<head>
<script>
var childFunction = new CV_childFunction();
function CJ_CJSDocHandler() {
}
CJ_CJSDocHandler.prototype = {
testFunction: function(){
alert();
}
}
</script>
</head>
<body>
test
</body>
</html>
728x90
728x90