在Mobile Safari中禁用相同来源策略 [英] Disable Same Origin Policy in Mobile Safari

查看:109
本文介绍了在Mobile Safari中禁用相同来源策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML5/JavaScript应用程序,该应用程序最初是为在某些汽车中运行而编写的.基本上,我需要将我的应用程序设置为在浏览器中运行,以便向客户进行简单演示.

I have an HTML5/JavaScript app that was originally written to run in certain cars. Basically, I need to set up my app to run in the browser for a simple demo to a customer.

我使用的是jQuery .ajax,这是由于同源政策引起的问题.我发现有很多方法可以在桌面浏览器中禁用此功能,而不能在移动浏览器中禁用.

I'm using jQuery .ajax which is causing problems due to the Same Origin Policy. I have found plenty of ways to disable this in desktop browsers, but not mobile ones.

我的目标是在Mobile Safari的iPad上演示该应用程序.有什么方法可以在iPad上暂时禁用同源策略"吗?

My goal is to demo the app on an iPad in Mobile Safari. Is there any way to temporarily disable the Same Origin Policy on an iPad?

推荐答案

我在sencha应用程序中遇到了同样的问题.我通过设置我的javascript ajax调用的基本路径来解决,例如:

I had the same problem with a sencha app. I resolved by setting a base path to my javascript ajax calls, example:

var BASEPATH = 'http://192.168.1.200/myapp';

$.ajax({
  url: BASEPATH+'/someaction'
});

然后从移动设备上使用http://192.168.1.200/myapp

And from the mobile I access it with http://192.168.1.200/myapp

我的问题是,我只能通过IP进行访问,而ajax调用的移动设备指向本地主机.

My problem was that the from mobile I get access only with IP but ajax call were point to localhost.

希望这个技巧会有所帮助.

Hope this trick helps.

这篇关于在Mobile Safari中禁用相同来源策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆