window.opener |不在铬工作 [英] window.opener | not working in chrome

查看:74
本文介绍了window.opener |不在铬工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



test1.html: -

 < html> 
< head>
< title>撰写< / title>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8>
< SCRIPT>
function test(){
// alert('');
var win = window.open('../ login / test2.html',,height = 700,width = 800);
}
function test1(){
alert('test1');
}
< / SCRIPT>
< / head>
< body>

< input type =buttonvalue =clickonclick =test(); />
< / body>
< / html>

test2.html: -

 < HTML> 
< head>
< title>< / title>
< SCRIPT>
function opener1(){
try {
if(window.opener!= null&&!window.opener.closed)
{

}
window.opener.test1();
} catch(e){alert(e.description);}
}
< / SCRIPT>
< / head>
< body oncontextmenu =return falseondragstart =return falseonload =opener1();>
< h1>测试页< / h1>

< / body>
< / html>

来自test2.html的test1.html中的调用方法not working..any solutions ..appreciated ..谢谢

解决方案

父窗口只能使用变量。
下面对opener1函数的修改应该使这成为可能

 函数opener1(){
try {
if(parent.window.opener!= null&&!parent.window.opener.closed)
{
parent.window.opener.test1();
}

} catch(e){alert(e.description);}
}


I am having two html pages..i am calling parent window from child..All things works great.but in Chrome it fails..let me know the reason..

test1.html :-

<html>
<head>
<title>Compose</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<SCRIPT>
function test(){
//alert('');
var win = window.open('../login/test2.html',"","height=700,width=800");
}
function test1(){
alert('test1');
}
</SCRIPT>
</head>
<body>

<input type="button" value="click" onclick="test();" />             
</body>
</html>

test2.html :-

<html>
<head>
<title></title>
<SCRIPT>
function opener1(){
try{
    if(window.opener != null && !window.opener.closed)
    {

    }
    window.opener.test1();
    }catch(e){ alert(e.description);}
}
</SCRIPT>
</head>
<body oncontextmenu="return false"  ondragstart="return false" onload="opener1();">
<h1>Test Page</h1>

</body>
</html>

Calling method in test1.html from test2.html not working..any solutions..appreciated..thanks

解决方案

the parent window can only be accessed using the parent variable. The following modification to opener1 function should make this possible

function opener1(){
    try{
        if(parent.window.opener != null && !parent.window.opener.closed)
        {
          parent.window.opener.test1();
        }

    }catch(e){ alert(e.description);}       
}

这篇关于window.opener |不在铬工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆