zl程序教程

您现在的位置是:首页 >  前端

当前栏目

javascript学习笔记(一)在html中使用javascript

2023-06-13 09:14:34 时间
1.延时脚本运行的方法:
方法一:把全部javascript引用放在<body>元素中,页面内容后,如
复制代码代码如下:

<html>
<head>
<title>示例1</title>
</head>
<body>
<!--页面内容-->
<scripttype="text/javascript"src="example1.js"></script>
<scripttype="text/javascript"src="example2.js"></script>
</body>
</html>

方法二:为<script>元素定义defer属性defer="defer",如
复制代码代码如下:

<html>
<head>
<title>示例1</title>
<scripttype="text/javascript"defer="defer"src="example1.js"></script>
<scripttype="text/javascript"defer="defer"src="example2.js"></script>
</head>
<body>
<!--页面内容-->
</body>
</html>