JS——js的结合方式

来源:互联网 发布:冒泡排序优化 编辑:程序博客网 时间:2024/05/16 02:40
一、在页面上使用script标签,在标签中书写js代码。举例:<html>  <head>    <title>js结合方式一.html</title>     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="this is my page">    <meta http-equiv="content-type" content="text/html; charset=UTF-8">    <script type="text/javascript">    alert("结合方式一");    </script>  </head>  <body>  </body></html>二、使用src属性引入外部js文件。注意:在引入外部js的script标签中,不能再书写js代码。举例:引用的外部js文件为2.js;alert("Combination Two");举例:<html>  <head>    <title>js结合方式二.html</title>     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="this is my page">    <meta http-equiv="content-type" content="text/html; charset=UTF-8">    <script type="text/javascript" src="2.js">    </script>  </head>  <body>  </body></html>
0 0
原创粉丝点击