您的位置:首页 > Web前端 > CSS

如何导入外部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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: