为什么我在JavaScript中使用moveTo会出错?

时间:2022-08-22 23:13:48

I am opening a new window from a button using var myWindow = window.open(...). I then want to move that window to the correct location on the screen. I use myWindow.moveTo(10,10) to do this but I get an Access Denied error.

我正在使用var myWindow = window.open(...)从按钮打开一个新窗口。然后,我想将该窗口移动到屏幕上的正确位置。我使用myWindow.moveTo(10,10)来做到这一点,但我得到一个Access Denied错误。

The window I open contains information from another server to the one I am executing on. When it isn't, the window moves correctly. Is this the limitation and is there a way around it?

我打开的窗口包含从另一个服务器到我正在执行的服务器的信息。如果不是,则窗口正确移动。这是限制吗?有办法吗?

I am using IE7. (The work is for an existing Intranet that includes lots of ActiveX so all users use IE7)

我正在使用IE7。 (该工作适用于包含大量ActiveX的现有Intranet,因此所有用户都使用IE7)

2 个解决方案

#1


3  

You could try to put the information from the other site in an iframe located on the same host that runs the window.open JavaScript. Or maybe even better, get the information server-side and present it directly from your site. Iframes can be trouble.

您可以尝试将来自其他站点的信息放在位于运行window.open JavaScript的同一主机上的iframe中。或者甚至更好,获取服务器端的信息并直接从您的站点提供。 iframe可能会有麻烦。

#2


1  

The window I open contains information from another server to the one I am executing on. When it isn't, the window moves correctly. Is this the limitation and is there a way around it?

我打开的窗口包含从另一个服务器到我正在执行的服务器的信息。如果不是,则窗口正确移动。这是限制吗?有办法吗?

Browsers security model have been increasingly restrictive over the last couple of years. What you could do a few years ago, isn't allowed any more. Blame it on advertising companies.

浏览器安全模型在过去几年中受到越来越多的限制。几年前你可以做什么,不再允许。归咎于广告公司。

#1


3  

You could try to put the information from the other site in an iframe located on the same host that runs the window.open JavaScript. Or maybe even better, get the information server-side and present it directly from your site. Iframes can be trouble.

您可以尝试将来自其他站点的信息放在位于运行window.open JavaScript的同一主机上的iframe中。或者甚至更好,获取服务器端的信息并直接从您的站点提供。 iframe可能会有麻烦。

#2


1  

The window I open contains information from another server to the one I am executing on. When it isn't, the window moves correctly. Is this the limitation and is there a way around it?

我打开的窗口包含从另一个服务器到我正在执行的服务器的信息。如果不是,则窗口正确移动。这是限制吗?有办法吗?

Browsers security model have been increasingly restrictive over the last couple of years. What you could do a few years ago, isn't allowed any more. Blame it on advertising companies.

浏览器安全模型在过去几年中受到越来越多的限制。几年前你可以做什么,不再允许。归咎于广告公司。