jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery-mobile – Phonegap和jquery手机:a href – >原始null不允许Access-Control-Allow-Origin大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用jQuery手机与手机间隙,在一个多页的文档.
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关于如何做你正在寻找…

希望这可以帮助!

大佬总结

以上是大佬教程为你收集整理的jquery-mobile – Phonegap和jquery手机:a href – >原始null不允许Access-Control-Allow-Origin全部内容,希望文章能够帮你解决jquery-mobile – Phonegap和jquery手机:a href – >原始null不允许Access-Control-Allow-Origin所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。