我有一个工作正常的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,不适用于设备(但适用于模拟器)
发布评论