简体   繁体   English

Window.opener在IE8中未定义?

[英]Window.opener undefined in IE8?

I can't figure out where I am going wrong with this. 我无法弄清楚我在哪里出错。 In other browsers, it works fine: 在其他浏览器中,它工作正常:

function main__pageeditor_new_body_SetUrl()
    {
        function getUrlParam(parentObject, paramName)
        {
          var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i') ;            
          var match = parentObject.location.search.match(reParam) ;

           return (match && match.length > 1) ? match[1] : '' ;
        }

        var funcNum = getUrlParam(this, 'CKEditorFuncNum');

        this.opener.CKEDITOR.tools.callFunction(funcNum, arguments[0]);
}

But in IE you get this error: 但在IE中你得到这个错误:

'this.opener.CKEDITOR' is null or not an object

Why wouldn't this work? 为什么这不起作用?

window.opener doesn't always work in IE8 for security reasons. 出于安全原因,window.opener并不总是在IE8中工作。 I think you can put the site(s) in the "trusted zone" so that it will allow window.opener to work. 我认为您可以将站点放在“受信任区域”中,以便它允许window.opener工作。

If the two windows are in different domains then it won't work in any browser due to the same origin policy. 如果两个窗口位于不同的域中,则由于相同的源策略,它将无法在任何浏览器中工作。

please test once that what is NULL ?? 请测试一下什么是NULL?

this.opener
or
this.opener.CKEDITOR

window.opener works when my security zone is 'Internet' in IE8. 当我的安全区域是IE8中的“Internet”时,window.opener正常工作。 Tried on Window Opener 试图打开窗口

Next, I wanted to try this on CKEDITOR itself so I went to CKEDITOR DEMO 接下来,我想在CKEDITOR上尝试这个,所以我去了CKEDITOR DEMO

There I opened a popup ' window.open ' using Developer Toolbar and in the popup, I executed following code which worked fine. 在那里,我使用开发人员工具栏打开了一个弹出窗口' window.open ',在弹出窗口中,我执行了以下代码,工作正常。

>>String(this.opener.CKEDITOR.tools.callFunction);

Response 响应

"function(f){var g=e[f];return g&&g.apply(window,Array.prototype.slice.call(arguments,1));}"

At this point when everything works for me, I would request you to upload your code. 此时,一切都适合我,我会要求您上传您的代码。

I found this with a simple search : http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/0c014e78-8d35-4df3-93da-7f6a30b4ed8b/ 我通过简单的搜索找到了这个: http//social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/0c014e78-8d35-4df3-93da-7f6a30b4ed8b/

The solution provided there is: 提供的解决方案是:

Under the Security Tab in your internet options, click on the Trusted Websites Icon. 在Internet选项的“安全”选项卡下,单击“可信网站”图标。 Now check the checkbox marked "Enable Protected Mode" and restart internet explorer. 现在选中标记为“启用保护模式”的复选框,然后重新启动Internet Explorer。

Another resource I found suggests to also remove the site from the trusted zone: 我发现的另一个资源建议也从受信任区域中删除该站点:

remove the site from Trusted sites list... it is probably already mapped to the same security zone as the opener (intranet). 从可信站点列表中删除该站点...它可能已经映射到与opener(intranet)相同的安全区域。 Select the File>Properties dialog in IE to determine which security zone a page/domain is mapped to. 在IE中选择“文件”>“属性”对话框,以确定页面/域映射到的安全区域。

Given that you've probably tried several suggestions so far, you might have changed enough settings to be in a weird configuration state. 鉴于到目前为止您可能已经尝试了几个建议,您可能已经更改了足够的设置以处于奇怪的配置状态。 I'd suggest you reset all your zone settings to the default and start from scratch. 我建议您将所有区域设置重置为默认设置并从头开始。

I have faced Issue window.opener getting null in my Web application running in http:/localhost:8080.If I placed the IP address/hostname instead of localhost then this issue doesn't occurred. 我遇到了问题window.opener在运行于http:/ localhost:8080的Web应用程序中获取null。如果我放置了IP地址/主机名而不是localhost,则不会发生此问题。

Lets check, I strongly believe this solution is helpful. 让我们检查一下,我坚信这个解决方案很有帮助。

Your "this" context could be getting changed, depending on how you use the function. 您的“此”上下文可能会发生变化,具体取决于您使用该功能的方式。

change: 更改:

this.opener.CKEDITOR.tools.callFunction(funcNum, arguments[0]);

to: 至:

window.opener.CKEDITOR.tools.callFunction(funcNum, arguments[0]);

Does that fix it? 这样可以解决吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM