简体   繁体   English

在Intranet中启用跨域脚本

[英]Enabling cross domain scripting in the intranet

I'm having a few problems with an application that integrates sharepoint, SQL reporting services and a bunch of custom forms that are built using ASP.NET MVC. 我在使用集成点,SQL报告服务和一堆使用ASP.NET MVC构建的自定义表单的应用程序时遇到了一些问题。

Assuming my servers are as follows; 假设我的服务器如下;

  • MOSS 苔藓
  • SSRS SSRS
  • Custom forms 自定义表单

In MOSS, my portal has need on occassion to popup a custom form to capture user input. 在MOSS中,我的门户网站需要在场合弹出一个自定义表单来捕获用户输入。 I've done this by using a jQuery dialog (using Boxy), which iframes the custom form in and passes the url of the portal into it. 我通过使用jQuery对话框(使用Boxy)来完成此操作,该对话框将自定义窗体iframe并将门户网站的url传入其中。 When the custom form is finished, it navigates the parent window (the MOSS portal) to the URL passed in, which effectively refreshes the page. 完成自定义表单后,它会将父窗口(MOSS门户)导航到传入的URL,从而有效地刷新页面。

This was working fine until we threw in the complexity of SSRS. 这很好,直到我们考虑到SSRS的复杂性。

Now in MOSS, I have a report that lists some data, but the SSRS report viewer web part seems to iframe it's report content in, which means the hyperlinks from the report can't ask the parent to overlay the same dialogs (as it's cross domain) and if it were to perform the overlay itself, it would just overlay the iframe. 现在在MOSS中,我有一个列出一些数据的报告,但是SSRS报告查看器web部分似乎是iframe的报告内容,这意味着来自报告的超链接不能要求父级覆盖相同的对话框(因为它是交叉的)如果要执行叠加本身,它只会覆盖iframe。

Sorry for the long post, getting to the point - this is an internal intranet application only. 对于这篇长篇文章感到抱歉,重点关注 - 这只是一个内部Intranet应用程序。 Is it possible to allow cross domain scripting somehow so that the popup dialogs can all be controlled from javascript within the sharepoint portal and SSRS and my custom forms can just invoke javascript methods on the parent? 是否有可能以某种方式允许跨域脚本,以便弹出对话框都可以从sharepoint门户和SSRS中的javascript控制,我的自定义表单可以只调用父级的javascript方法?

Preferably I wouldn't want to have to do configuration in the client browser to allow this to happen, as I'd have to roll that change out to all the machines within the estate - which is a significant number. 最好我不想在客户端浏览器中进行配置以允许这种情况发生,因为我必须将更改滚动到庄园内的所有机器 - 这是一个重要的数字。

Thanks in advance, beer available to anyone who can solve my woes ;) 在此先感谢,任何能解决我的困境的人都可以喝啤酒;)

Cheers, Tony 干杯,托尼

IE8, Firefox 3, recent Opera and Safari/Chrome support postMessage which allows cooperating pages on different domains to talk to each other: IE8,Firefox 3,最近的Opera和Safari / Chrome支持postMessage,它允许不同域上的合作页面相互通信:

http://ajaxian.com/archives/cross-window-messaging-with-html-5-postmessage http://ajaxian.com/archives/cross-window-messaging-with-html-5-postmessage

If you are stuck with older browsers, you have few options. 如果您遇到旧版浏览器,则几乎没有选择。 The cleanest is to send everything that needs to communicate with each other through the same proxy, although in the OP's situation it looks like this isn't possible. 最干净的是通过相同的代理发送需要相互通信的所有内容,尽管在OP的情况下看起来这是不可能的。

The next cleanest is to use Flash's cross-domain facility. 下一个最干净的是使用Flash的跨域设施。

Another option is xssinterface , which wraps postMessage where available and uses some voodoo involving cookies and polling where it isn't. 另一种选择是xssinterface ,它将postMessage包装在可用的地方,并使用一些涉及cookie的voodoo和不在其中的轮询。

The only other option is to use hidden iframes - to send a message to a page, change the iframe's location to one on the destination page's domain and poll in the destination page - but again I think the proxying in the OP's case makes this unworkable. 唯一的另一个选择是使用隐藏的iframe - 向页面发送消息,将iframe的位置更改为目标页面的域上的一个并在目标页面中轮询 - 但我再次认为OP的情况下的代理使得这不可行。

There is another option in addition to those Andrew provides. 除了安德鲁提供的那些之外,还有另一种选择。 You can dynamically inject script tags into the DOM, wherein the src attribute can point to a javascript file on any domain. 您可以动态地将脚本标记注入DOM,其中src属性可以指向任何域上的javascript文件。

In jQuery you accomplish this by specifying "jsonp" as the datatype for the ajax request. 在jQuery中,您可以通过将“jsonp”指定为ajax请求的数据类型来实现此目的。 You can read more about this approach here: 您可以在此处详细了解此方法:

http://blog.ropardo.ro/2009/09/23/cross-domain-ajax-calls/ http://blog.ropardo.ro/2009/09/23/cross-domain-ajax-calls/

I finally got around these issues by using hidden iframes as suggested. 我终于通过使用隐藏的iframe来解决这些问题。 I posted an article on my blog with more details and pushed the code onto codeplex: 我在我的博客上发布了一篇文章,其中包含更多细节,并将代码推送到codeplex:

http://www.deepcode.co.uk/2009/11/overcoming-cross-domain-issues-between.html http://www.deepcode.co.uk/2009/11/overcoming-cross-domain-issues-between.html

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

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