Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我需要寻找什么变量来知道何时回退jQuery Mobile的本地副本?_Javascript_Jquery Mobile - Fatal编程技术网

Javascript 我需要寻找什么变量来知道何时回退jQuery Mobile的本地副本?

Javascript 我需要寻找什么变量来知道何时回退jQuery Mobile的本地副本?,javascript,jquery-mobile,Javascript,Jquery Mobile,我已经在使用了,但是现在我想对jqMobile做同样的事情,如果可能的话 他们提供CDN,所以这显然是第一步。但是如果我要使用jqueryinclude中的类似解决方案,我必须检查变量的存在性。我可以检查哪些内容来确定CDN jqMobile include是否成功 <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>

我已经在使用了,但是现在我想对jqMobile做同样的事情,如果可能的话

他们提供CDN,所以这显然是第一步。但是如果我要使用jqueryinclude中的类似解决方案,我必须检查变量的存在性。我可以检查哪些内容来确定CDN jqMobile include是否成功

<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<script type="text/javascript">
  if (typeof ?????? == 'undefined')
  {
    document.write(unescape("%3Cscript src='/path/to/your/jquery-mobile.js' type='text/javascript'%3E%3C/script%3E"));
  }
</script>

如果(类型为未定义)
{
write(unescape(“%3Cscript src=”/path/to/your/jquery mobile.js'type='text/javascript'%3E%3C/script%3E”);
}

这似乎有效,但我不能保证这是一个完美的解决方案:

<script src="http://codezzzzzz.jqueryzzzzz.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<script type="text/javascript">if (typeof jQuery.widget == 'undefined'){document.write(unescape("%3Cscript src='assets/jquery.mobile-1.0.min.js' type='text/javascript'%3E%3C/script%3E"));}</script>

if(typeof jQuery.widget=='undefined'){document.write(unescape(“%3Cscript src='assets/jQuery.mobile-1.0.min.js'type='text/javascript'%3E%3C/script%3E”);}

请注意,CDN副本的域被故意弄乱,以便能够测试回退。应该是
code.jquery.com

我认为测试
$是安全的。mobile
对象:

if (typeof $.mobile == 'undefined')
  {
    document.write(unescape("%3Cscript src='/path/to/your/jquery-mobile.js' type='text/javascript'%3E%3C/script%3E"));
  }
在这里查看:


在该示例中,url已断开,因此它尝试加载它。5秒钟后,它再次检查。

jQuery是一个跨浏览器JavaScript库,旨在简化HTML的客户端脚本。它于2006年1月由John Resig在纽约巴坎普发布。在10000个访问量最大的网站中,超过49%的网站使用jQuery,jQuery是目前使用的最流行的JavaScript库。你可以参考这里了解更多关于