CORS + Android Webview,不适用于设备(​​但适用于模拟器)

编程入门 行业动态 更新时间:2024-10-25 10:34:06
本文介绍了CORS + Android Webview,不适用于设备(​​但适用于模拟器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个工作正常的HelloWorld phonegap程序,其中包含jquery mobile,如下所述: jquerymobile/demos/1.1.0/docs/about/getting-started.html .我为此添加了一些JavaScript来进行跨源资源共享的实验:

I have a working HelloWorld phonegap program with jquery mobile sprinkled in as described here: jquerymobile/demos/1.1.0/docs/about/getting-started.html. I added a little javascript to this to experiment with Cross Origin Resource Sharing:

<script> $(document).bind("pageinit", function() { $.support.cors = true; $.mobile.allowCrossDomainPages = true; $.mobile.changePage("jquery"); }); </script>

这在模拟器(2.3)上效果很好,jquery已通过jquery移动演示加载.但是,在实际的2.3 Android设备(运行Cyanogen的T-mobile G2,Galaxy SII,Galaxy Player)上,changePage()调用没有任何作用.

This works great on the emulator (2.3), jquery is loaded over the jquery mobile demo. However, on actual 2.3 Android devices (T-mobile G2 running Cyanogen, Galaxy SII, Galaxy Player) the changePage() call does nothing.

推荐答案

尝试使用 mobileinit 而不是 pageinit .因为您绑定的事件是普通的jQuery,而对于jQuery mobile,则初始化事件为mobileinit.

Try mobileinit instead of pageinit. Because event you bound to is normal jQuery and for jQuery mobile the initialization event is mobileinit.

必须在任何跨域请求之前设置$ .mobile.allowCrossDomainPages选项,因此我们建议将其包装在mobileinit处理程序中.

The $.mobile.allowCrossDomainPages option must be set before any cross-domain request is made so we recommend wrapping this in a mobileinit handler.

更多推荐

CORS + Android Webview,不适用于设备(​​但适用于模拟器)

本文发布于:2023-11-27 05:09:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636730.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   模拟器   不适用于   设备   CORS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!