我试图使用jQuery手机与手机间隙,在一个多页的文档.
Tring在文档中使用基本的href链接,给出Origin null是不允许的Access-Control-Allow-Origin错误,这是非常讨厌的.
Tring在文档中使用基本的href链接,给出Origin null是不允许的Access-Control-Allow-Origin错误,这是非常讨厌的.
这是因为索引页面通过file://而不是http://该webkit解释为origin为null.有没有人有jQuery手机和电话沟通在多页面环境中工作?如果可以这样做呢?如果在href标签中添加rel = external,链接就可以工作,但是所有的转换当然都会丢失.
不能在堆栈溢出或者互联网上找到有关此特定问题的任何信息.
<!DOCTYPE HTML> <html> <head> <title>PhoneGap</title> <script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" /> <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script> $(document).bind( "mobileinit",function(){ //alert("mobileinit fired"); $.support.cors = true; $.mobile.allowCrossDomainPages = true; }); </script> <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script> <script type="text/javascript"> function onDeviceReady() { navigator.network.isReachable("google.com",reachableCallback,{}); } // Check network status function reachableCallback(reachability) { // There is no consistency on the format of reachability var networkState = reachability.code || reachability; var states = {}; states[NetworkStatus.NOT_REACHABLE] = 'No network connection'; states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection'; states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection'; if (networkState != 0) online = true; } var online = navigator.onLine || false; $(document).ready(function() { $(document).bind('deviceready',function(){ onDeviceReady() }) // Your main code }) //Now if you about to make an AJAX call to load up some dynamic data,you can easily check to see if you're online if(online) { } else { } </script> </head> <body> <h1>Welcome to PhoneGap</h1> <a href="edit.html">Edit html</a> </body> </html>
解决方法
这是
official documentation关于如何做你正在寻找…
希望这可以帮助!