通过域之间的JavaScript进行通信 [英] Communicating via javascript across domains
问题描述
嘿所有,
这就是情况:
- 两个网站,一个在domain1上,另一个在domain2上br />
- domain1打开一个新窗口,这是一个来自domain2的javascript应用程序
- domain1需要与domain2上的javascript应用程序进行通信
问题出现在最后一步。出于安全原因,浏览器不允许跨域访问
,这是正确的。尽管如此,我仍然需要与应用程序进行通信。我可以重新加载窗口
通过网址传递必要的命令,但这很慢,因为
整个javascript应用程序必须重新加载。
任何人都有任何想法绕过这个限制,这将是半效率,至少比重新加载应用程序更有效吗?签署
由于成本原因,脚本不是一个选项。我可以控制两个
的网站,所以我可以做任何需要做的事情。
问候,
克雷格< br>
Hey all,
Here''s the situation:
- two websites, one on domain1 and the other on domain2
- domain1 opens a new window which is a javascript app from domain2
- domain1 needs to communicate with the javascript app on domain2
The problem occurs in that last step. Browsers don''t allow script access
across domains for security reasons, rightly so. Nonetheless, I still
need to communicate with the application. I can reload the window
passing the necessary commands through the url, but this is slow because
the whole javascript app must reload.
Anyone have any ideas about a way around this limitation that would be
semi-efficient, at least more efficient than reloading the app? Signing
the script isn''t an option for cost reasons. I have control over both
sites, so I can do anything that needs to be done.
Regards,
Craig
推荐答案
Craig写道:
Craig wrote:
嘿所有,
这里是情况:
- 两个网站,一个在domain1上,另一个在domain2上
- domain1打开一个新窗口,这是一个来自domain2的javascript应用程序
- domain1需要与之通信domain2上的javascript应用程序
问题发生在最后一步。出于安全原因,浏览器不允许跨域访问脚本,这是正确的。尽管如此,我仍然需要与应用程序进行通信。我可以重新加载窗口
通过url传递必要的命令,但这很慢,因为整个javascript应用程序必须重新加载。
任何人都有任何想法绕过这个限制将是半效率,至少比重新加载应用程序更有效?签署
由于成本原因,脚本不是一种选择。我可以控制两个网站,所以我可以做任何需要做的事情。
问候,
克雷格
Hey all,
Here''s the situation:
- two websites, one on domain1 and the other on domain2
- domain1 opens a new window which is a javascript app from domain2
- domain1 needs to communicate with the javascript app on domain2
The problem occurs in that last step. Browsers don''t allow script access
across domains for security reasons, rightly so. Nonetheless, I still
need to communicate with the application. I can reload the window
passing the necessary commands through the url, but this is slow because
the whole javascript app must reload.
Anyone have any ideas about a way around this limitation that would be
semi-efficient, at least more efficient than reloading the app? Signing
the script isn''t an option for cost reasons. I have control over both
sites, so I can do anything that needs to be done.
Regards,
Craig
嗯,它不是一个跨浏览器的解决方案,但如果你使用超文本
应用程序(HTA),你可以绕过一些安全性。当我想要IE的DOM检查器时,我做了类似
的事情。不幸的是,HTA在IE中只能运行
。我认为其他
系统有类似的浏览器特定解决方案,但我不知道。您可以在以下网址阅读有关HTA的更多信息:
http: //msdn.microsoft.com/workshop/a...node_entry.asp
Brian
Well, it is not a cross-browser solution, but if you use HyperText
Applications (HTA), you can bypass some security. I did something like
that when I wanted a DOM inspector for IE. Unfortunately HTA only works
in IE. I think there are similar browser-specific solutions for other
systems, but I dont know offhand. You can read more about HTA at:
http://msdn.microsoft.com/workshop/a...node_entry.asp
Brian
In文章< Ce ******************* @ news20.bellglobal.com>,
craig @ _netscene.org 启发我们...
In article <Ce*******************@news20.bellglobal.com>,
craig@_netscene.org enlightened us with...
任何人都有任何关于绕过这种限制的方法的想法,这将是半效率的,至少更多比重新加载应用程序更有效吗?
Anyone have any ideas about a way around this limitation that would be
semi-efficient, at least more efficient than reloading the app?
Cookies。
不是最好的,但总比没有好。
- -
-
~kaeli~
如果一本关于失败的书没有卖,它是否成功?
http://www.ipwebdesign.net/wildAtHeart
Cookies.
Not the best, but better than nothing.
--
--
~kaeli~
If a book about failures doesn''t sell, is it a success?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
> - 两个网站,一个在domain1上,另一个在domain2上
> - two websites, one on domain1 and the other on domain2
- domain1打开一个新窗口,这是一个来自domain2的javascript应用程序
- domain1需要与domain2上的javascript应用程序进行通信/>
问题发生在最后一步。出于安全原因,浏览器不允许跨域访问脚本,这是正确的。尽管如此,我仍然需要与应用程序进行通信。我可以重新加载窗口
通过url传递必要的命令,但这很慢,因为整个javascript应用程序必须重新加载。
- domain1 opens a new window which is a javascript app from domain2
- domain1 needs to communicate with the javascript app on domain2
The problem occurs in that last step. Browsers don''t allow script access
across domains for security reasons, rightly so. Nonetheless, I still
need to communicate with the application. I can reload the window
passing the necessary commands through the url, but this is slow because
the whole javascript app must reload.
如果这些网站共享一个公共域,然后您可以使其工作。对于
示例,如果您有''domain1.commom.com''和''domain2.common.com'',那么你可以将
放入< / b ; head> s:
document.domain =''common.com'';
这将绕过相同的网站规则。
http://www.crockford.com/
If the sites share a common domain, then you can make it work. For
example, if you have ''domain1.commom.com'' and ''domain2.common.com'', you
can put the following in the <head>s:
document.domain = ''common.com'';
This will get around the same site rule.
http://www.crockford.com/
这篇关于通过域之间的JavaScript进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!