简体   繁体   English

window.opener在ie中未定义,但在chrome中未定义,ff

[英]window.opener is undefined in ie but not chrome, ff

I open a new page and in IE(Using ie 11) window.opener is undefined. 我打开一个新页面,并在IE(使用ie 11)window.opener中未定义。 The window reference that window.open returns also is full of undefined or an empty Object . window.open返回的窗口引用也充满未定义或空的Object

My newly opened page needs to get the Xrm Object from the main page, since I cannot get it otherwise and need it to do all my functionality. 我新打开的页面需要从主页获取Xrm对象,因为否则我将无法获取它,并且需要它来执行我的所有功能。 Code: 码:

 function openCountyTab() { countyTabRef = window.open("countyTab", "countyTab"); return false; } 

And in the js file of the new tab I have var opener; window.onload = function() { ... opener = window.opener; ...} 在新标签的js文件中,我有var opener; window.onload = function() { ... opener = window.opener; ...} var opener; window.onload = function() { ... opener = window.opener; ...}

I have tried many things, including sending it to the full url, using a Blob and creating a url from that (which returns access denied), I also need to mention that when sending window.open("fullDomainName") the Object I get back is filled with <Access Denied> tags. 我已经尝试了很多方法,包括使用Blob将其发送到完整的url并从中创建一个url(这将返回拒绝访问),我还需要提到在发送window.open("fullDomainName")我得到的Object后面填充了<Access Denied>标签。

Edit: I will state my problem more clearly. 编辑:我将更清楚地陈述我的问题。 I need to open a new HTML page that is on the same domain and it needs to either get passed the Xrm object or get it from the window that opened it. 我需要打开一个位于同一域中的新HTML页面,并且需要传递Xrm对象或从打开它的窗口中获取它。 Now, the Xrm object is needed because I use it in my script that runs on this newly opened page. 现在,需要Xrm对象,因为我在新打开的页面上运行的脚本中使用了它。 Specifically, it is needed for a lib that I am using called XrmServiceToolKit . 具体来说,我正在使用的名为XrmServiceToolKit的库需要它。

I use this to retrieve and modify data on a server on Microsoft's CRM Platform. 我使用它来检索和修改Microsoft CRM平台上的服务器上的数据。 I have no issue with doing any of that since everything runs fine on Chrome, FF. 我做任何事情都没有问题,因为在FF,Chrome上一切正常。 The problem is that the XrmServiceToolKit cannot get the context ie the Xrm Object because it is null or undefined on the page. 问题是XrmServiceToolKit无法获取contextXrm对象,因为它在页面上为nullundefined Therefore I cannot run my script as it depends on this. 因此,我不能运行我的脚本,因为它依赖于此。 Therefore, I need a way to open a new page (not replace current window) in IE11 and give it this Xrm object. 因此,我需要一种在IE11中打开新页面(而不是替换当前窗口)并将其提供给Xrm对象的方法。

Hopefully that clears it up. 希望这可以清除它。

Any help is greatly appreciated! 任何帮助是极大的赞赏!

The Browser Compatibility table in MDN for window.opener only lists Chrome, Firefox, and Android Webview as supporting this variable, all other browsers are unknown, and apparently not compatible. MDN for window.opener浏览器兼容性”表仅列出支持此变量的Chrome,Firefox和Android Webview,所有其他浏览器都是未知的,并且显然不兼容。

So you should not depend on it in applications that need to be portable to all browsers. 因此,您不应在需要可移植到所有浏览器的应用程序中依赖它。

If you need to communicate between a window and another window that it opens, take a look at the postMessage mechanism. 如果需要在一个窗口和另一个窗口之间进行通信,请查看postMessage机制。

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

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