当没有Internet连接时使用jQuery [英] Working with jQuery when there is no Internet connection

查看:95
本文介绍了当没有Internet连接时使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对jQuery完全陌生。当使用jQuery时,我断开了互联网,以检查我的网页是否正常没有互联网连接。它显示了一些不是必需的东西。当我看到源代码,它显示:

 < link rel =stylesheethref =http:// jquery .com / jquery-wp-content / themes / jquery / css / base.css?v = 1> 

所以我下载了代码并保存在我的根文件夹中。仍然不工作。我想知道我们是否可以在离线时使用jQuery?



这是我的代码:

 <!doctype html> 
<! - [if IE 7]> < html class =no-js ie ie7 lte7 lte8 lte9lang =zh-CN> <![endif] - >
<! - [if IE 8]> < html class =no-js ie ie8 lte8 lte9lang =en-US> <![endif] - >
<! - [if IE 9]> < html class =no-js ie ie9 lte9> lang =en-US> <![endif] - >
<! - [if(gt IE 9)|!(IE)]><! - < html class =no-jslang =en-US> <! - <![endif] - >
< head>
< meta charset =utf-8>
< meta http-equiv =X-UA-Compatiblecontent =IE = border,chrome = 1>
< title>首页< / title>
< meta name =authorcontent =jQuery Foundation - jquery.org>
< meta name =descriptioncontent =jQuery:The Write Less,Do More,JavaScript Library>
< meta name =viewportcontent =width = device-width>

< link rel =stylesheethref =http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1>
< script src =jquery.min.js>< / script>
<! - [if lt IE 7]>< link rel =stylesheethref =css / font-awesome-ie7.min.css><![endif] - >
< script> try {Typekit.load();} catch(e){}< / script>
< meta name =generatorcontent =WordPress 3.5.1/>

< / head>
< body>

<! - [if lt IE 7]>
< p class =chromeframe>您使用的是过时的浏览器。
< a href =http://browsehappy.com/>立即升级您的浏览器< / a>
或< a href =http://www.google.com/chromeframe/?redirect=true>安装
Google Chrome内嵌框架< / a>以更好地体验此网站。< / p>
<![endif] - >

< header>
< section id =global-nav>
< nav>
< div class =constrain>
< ul class =links>
< li>< a href =home.jsp>首页< / a>< / li>
< li class =dropdown>< a href =CreatPatient.jsp> Patient< / a>
< ul>
< li>< a href =CreatePatient.jsp>创建患者< / a>< / li>
< li>< a href =编辑患者>编辑患者< / a>< / li>
< / ul>
< / li>
< li class =dropdown>< a href =Appointments.jsp>约会< / a>
< ul>
< li>< a href =CreateAppointments.jsp>创建约会< / a>< / li>
< li>< a href =EditAppointments.jsp />编辑约会< / a>< / li>
< / ul>
< / li>
< li class =dropdown>< a href =#>报告< / a>
< ul>
< li>< a href =PreOperative.jsp> Pre Operative< / a>< / li>
< li>< a href =IntraOperative.jsp> Intra Operative< / a>< / li>
< li>< a href =PostOperative.jsp> PostOperative< / a>< / li>
< / ul>
< / li>
< / ul>
< / div>
< / nav>
< / section>
< / header>
< / body>
< / html>

当我删除此行时:

 < link rel =stylesheethref =http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1> 

这会产生问题。



已下载jQuery并保留在桌面上。 HTML文件也在桌面上。请告诉我为什么它不工作。

解决方案

是的,这是可能的。你提到你下载的文件 - 这是一个好的第一步,但你还必须改变所有的 href src 参考。



例如,

 < link rel =stylesheethref =http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1> 

应为

 < link rel =stylesheethref =base.css> 






还要记住获取离线版本的jQuery JS库:

下载 jquery.js ,将其放入你的根文件夹&参考:

 < script src =jquery-1.9.1.min.js>< / script> 

如果您想在子目录中使用它:

 < script src =[subdirectory-name] /jquery-1.9.1.min.js< / script> 






请记住 >需要离线和在您的工作本地目录。这意味着您不能删除样式表 jQuery JS库



此外,将< script> 标签在< head> 是不好的做法;






你的代码现在应该看起来(简而言之,注意我没有太多)像:

  ... 
< html class =no-jslang =en-US>
< head>
...
< link rel =stylesheethref =base.css>
...
< / head>
< body>
...
< script src =jquery.min.js>< / script>
< / body>
< / html>再次确保 base.css jquery.min.js 是与 .html相同的文件夹中的确切文件名 文件


I am completely new to jQuery. When working with jQuery, I disconnected the Internet to check if my webpage works fine without an Internet connection. It displayed some thing which is not required. When I saw the source code, it displayed:

<link rel="stylesheet" href="http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1">

So I downloaded the code and kept it in my root folder. Still it's not working well. I wanted to know whether we can work with jQuery whilst offline?

Here is my code:

<!doctype html>
<!--[if IE 7 ]>      <html class="no-js ie ie7 lte7 lte8 lte9" lang="en-US"> <![endif]-->
<!--[if IE 8 ]>      <html class="no-js ie ie8 lte8 lte9" lang="en-US"> <![endif]-->
<!--[if IE 9 ]>      <html class="no-js ie ie9 lte9>" lang="en-US"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title> Home</title>
    <meta name="author" content="jQuery Foundation - jquery.org">
    <meta name="description" content="jQuery: The Write Less, Do More, JavaScript Library">
    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1">
    <script src="jquery.min.js"></script>
    <!--[if lt IE 7]><link rel="stylesheet" href="css/font-awesome-ie7.min.css"><![endif]-->
    <script>try{Typekit.load();}catch(e){}</script>
    <meta name="generator" content="WordPress 3.5.1" />

</head>
<body >

<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. 
<a href="http://browsehappy.com/">Upgrade your browser today</a> 
or <a href="http://www.google.com/chromeframe/?redirect=true">install 
Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->

<header>
    <section id="global-nav">
        <nav>
            <div class="constrain">
                <ul class="links">
                    <li><a href="home.jsp">Home</a></li>
                    <li class="dropdown"><a href="CreatPatient.jsp">Patient</a>
                        <ul>
                            <li><a href="CreatePatient.jsp">Create Patient</a></li>
                            <li><a href="Edit Patient">Edit Patient</a></li>
                        </ul>
                    </li>
                    <li class="dropdown"><a href="Appointments.jsp">Appointments</a>
                        <ul>
                            <li><a href="CreateAppointments.jsp">Create Appointments</a></li>
                            <li><a href="EditAppointments.jsp/">Edit Appointments</a></li>
                        </ul>
                    </li>
                    <li class="dropdown"><a href="#">Reports</a>
                        <ul>
                            <li><a href="PreOperative.jsp">Pre Operative</a></li>
                            <li><a href="IntraOperative.jsp">Intra Operative</a></li>
                            <li><a href="PostOperative.jsp">PostOperative</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </section>
</header>
</body>
</html>

When I remove this line:

<link rel="stylesheet" href="http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1">

It creates a problem.

I have downloaded jQuery and kept on the desktop. The HTML file is also on the desktop. Please tell me why it's not working.

解决方案

Yes, it's possible. You've mentioned that you downloaded the file - that's a good first step, but you also have to change all the href and src references.

For example,

<link rel="stylesheet" href="http://jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1">

should become

<link rel="stylesheet" href="base.css">


Also remember to get the offline version of the jQuery JS library, too:
Download jquery.js, put it in your root folder & reference it:

<script src="jquery-1.9.1.min.js"></script>

And if you want it in a subdirectory:

<script src="[subdirectory-name]/jquery-1.9.1.min.js"></script>


Remember that both files need to be offline and in your working local directory. This means that you cannot remove the stylesheet nor the jQuery JS library. Keep both of them, in the local formats I've mentioned above.

Also, putting the <script> tag in the <head> is bad practice; move it just before the </body> tag instead.


Your code should now look (in short, note that I haven't put much) like:

...
<html class="no-js" lang="en-US">
<head>
    ...
    <link rel="stylesheet" href="base.css">
    ...
</head>
<body>
    ...
    <script src="jquery.min.js"></script>
</body>
</html>

Again, make sure that base.css and jquery.min.js are the exact file names and are in the same folder as this .html file

这篇关于当没有Internet连接时使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆