如何导入外部JS文件和Css文件
2012-07-21 12:10
239 查看
############################ 导入外部js文件:##################################
1.<script type="text/javascript" src="myjs/xx.js"></script>
2.<script language="javascript" src="myjs/xx.js"></script>
这里的</script>不能丢,也不能写成<script type="text/javascript" src="myjs/xx.js"/>这种形式,因为容易找不到外部js文件(src属性同img的src)。注意:type是一个未来趋势,在HTML 4 标准里并不赞成使用language属性,而赞成使用type属性。language属性可以用来指定使用哪种脚本语言,而type属性可以指定脚本语言的MIME类型。
从理论上而言,为脚本语言指定MIME类型比指定脚本语言名称要科学得多,但事实上只有拥有w3cDOM性能(IE5+)的浏览器才支持type,不过都支持language属性。但是毕竟已经不再推荐使用language属性,所以最好还是使用type。
############################ 导入外部css文件: #################################
<link rel="stylesheet" type="text/css" href="/css/mycss.css"/>
rel、stylesheet属性作用:首先,link标签是用于当前文档引用外部文档的;
其次,这个标签的rel属性用于设置对象和链接目的间的关系,说白了就是指明你链进来的对象是个什么东西的;
具体的值及其所表示的关系如下:
Alternate:Substitute version of the file that contains the link.
Appendix:Page that is an appendix for the set of pages.
Bookmark:Bookmark.
Chapter:Page that is a chapter for a set of pages.
Contents:Table of contents document.
Copyright:Copyright notice for the current page.
Glossary:Glossary for the current page.
Help:Help document.
Index:Index document for the current page.
Next:Next document in a sequence.
Offline:href that contains a path to the CDF file to be used for an offline favorite.
Prev:Previous document in a sequence.
Section:Page that is a section for a set of pages.
Shortcut:Icon href that contains a path to an icon file to be used for the favorite or link.
Start:First document of a set.
Stylesheet:Style sheet.
Subsection:Page that is a subsection for a set of pages.
1.<script type="text/javascript" src="myjs/xx.js"></script>
2.<script language="javascript" src="myjs/xx.js"></script>
这里的</script>不能丢,也不能写成<script type="text/javascript" src="myjs/xx.js"/>这种形式,因为容易找不到外部js文件(src属性同img的src)。注意:type是一个未来趋势,在HTML 4 标准里并不赞成使用language属性,而赞成使用type属性。language属性可以用来指定使用哪种脚本语言,而type属性可以指定脚本语言的MIME类型。
从理论上而言,为脚本语言指定MIME类型比指定脚本语言名称要科学得多,但事实上只有拥有w3cDOM性能(IE5+)的浏览器才支持type,不过都支持language属性。但是毕竟已经不再推荐使用language属性,所以最好还是使用type。
############################ 导入外部css文件: #################################
<link rel="stylesheet" type="text/css" href="/css/mycss.css"/>
rel、stylesheet属性作用:首先,link标签是用于当前文档引用外部文档的;
其次,这个标签的rel属性用于设置对象和链接目的间的关系,说白了就是指明你链进来的对象是个什么东西的;
具体的值及其所表示的关系如下:
Alternate:Substitute version of the file that contains the link.
Appendix:Page that is an appendix for the set of pages.
Bookmark:Bookmark.
Chapter:Page that is a chapter for a set of pages.
Contents:Table of contents document.
Copyright:Copyright notice for the current page.
Glossary:Glossary for the current page.
Help:Help document.
Index:Index document for the current page.
Next:Next document in a sequence.
Offline:href that contains a path to the CDF file to be used for an offline favorite.
Prev:Previous document in a sequence.
Section:Page that is a section for a set of pages.
Shortcut:Icon href that contains a path to an icon file to be used for the favorite or link.
Start:First document of a set.
Stylesheet:Style sheet.
Subsection:Page that is a subsection for a set of pages.
相关文章推荐
- django1.4模板中如何导入js、css等外部文件
- Django模板中如何导入js、css等外部文件
- 使用express框架,如何在ejs文件中导入外部的js、css文件
- Django模板中如何导入js、css等外部文件
- vue如何导入外部js文件(es6)
- eclipse项目中从外部导入的js文件报错如何解决
- vue如何导入外部js文件(es6)
- js模拟import方法导入外部文件
- MyEclipse如何导入外部.jar架包,解决项目文件乱码问题
- 使用SiteMesh(2.4.2) ,被装饰页面导入的外部js文件无法调用的问题
- 如何导入外部的frm、MYD、MYI文件到自己的mysql上查看
- 如何导入外部的frm、MYD、MYI文件到自己的mysql上查看
- 导入外部JS文件和外部CSS文件以及定义样式表
- 外部的js文件 如何用el表达式
- JavaScript或MyEclipse—如何解决js文件导入到MyEclipse工程后出错?
- 如何让浏览器访问最新的js、css等外部引用文件?
- Android如何导入已有的外部数据库(在raw下自己导入db文件)
- BSP中如何引用外部文件(JS/CSS等)及复杂功能的组织实现
- Vue导入外部js文件或css文件
- 如何解决外部JavaScript文件即JS乱码问题