Javascript—①你好,世界!

版权声明:未经允许禁止转载,否则会计入黑名单:http://www.cnblogs.com/123it/p/copyright.html

已授权以下网站转载

 

新手Perfect教程之Javascript教程①—你好,世界!

前言:不知道Javascript是什么东东的自行度娘或google一下

Javascript在html<head>和<body>里都行,但是必须在<script>里,就像这样:

 1 <!DOCTYPE  html>
 2 <html>
 3 <head>
 4 <script>
 5 //Edit JavaScript in here
 6 </script>
 7 </head>
 8 <body>
 9 </body>
10 </html>

或者这样:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 </head>
 5 <body>
 6 <script>
 7 //Edit JavaScript in here
 8 </script>
 9 </body>
10 </html>

 注意:IE5+6还需要<script>里加上"type="text/javascript",但是在html5里默认的就是Javascript。

以下代码为本篇教程的重点:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 </head>
 5 <body>
 6 <script>
 7 alert("hello world!");        //打开页面时弹出对话框"hello world!"
 8 </script>
 9 </body>
10 </html>

在上面的代码中,用户打开页面时会弹出对话框,内容是hello world!(alert是弹出对话框语句,以后会讲到)

————————The End————————

下期预告:新手Perfect教程之Javascript—②函数

我们下期再见!

作者:wy14abcd

未经允许不得转载

posted @ 2017-02-18 22:24  御坂12456  阅读(451)  评论(0编辑  收藏  举报

版权声明:未经允许禁止转载,否则会计入黑名单:http://www.cnblogs.com/123it/p/copyright.html

友情链接:HuiSky