HTML脚本
脚本(script)是一种批处理文件的延伸,一种纯文本保存的程序,由系统的一个解释器,将其翻译成机器码,并按顺序执行。
<script>元素定义客户端脚本,如JavaScript
既可包含脚本语句,也可通过src属性
必需的 type 属性规定脚本的 MIME 类型
<html>
<body>
<script type="text/javascript">
document.write("<h1>Hello world!</h1>")
document.write("hello world!")
</script>
</body>
</html>
说明:
MIME(媒体类型,Multipurpse Internet Mail Extensions)
是一种标准,用于表示文档、文件、或字节流的性质和格式
格式:type/subtype
其对大小写不敏感,一般采用小写
text/html
image/jpeg
audio/*
vidwo/mp4
<noscript>标签
浏览器不支持脚本时,显示内容
<script type="text/javascript">
document.write("hello world!")
</script>
<noscript>Your browser does not support this script!
</noscript>
HTML文件路径
<img src="picture.jpg">
jpg文件位于与当前网页相同的文件夹
<img src="images/picture.jpg">
jpg文件位于当前文件夹的images文件夹中
<img src="/images/picture.jpg">
jpg位于当前站点根目录的images文件夹中
<img src="../picture.jpg">
jpg位于当前文件夹的上一级文件夹中
说明:
尽可能使用相对路径(相对于当前文件的路径)