html当中如何引用js文件

3)html当中如何引用js文件

马克-to-win:如果需要javascript工程师和html美工各干各的工作,需要分开写文件。

例 1.2


<html>
<head>
    <script src="Hello.js"></script>
    <title></title>
</head>
<body>
</body>
</html>



Hello.js(如果你用notepad建立一个txt之后你再改为js,一定在存时,要存成utf-8或unicode格式):

    var a ;
    /*before you set value, a' type can not be defined.*/
    document.writeln(typeof(a) + "<br>他们");
    a = true;
    document.writeln(typeof(a) + "<br>");
    /*下面的console.log只有安装了firebug的firebox不报错*/
    console.log("This is the 1 message 马克-to-win write in %s", a);
    document.writeln(a);


2.简单语法:


例 2.1

<html>
<head>
</head>
<body>
<script type="text/javascript">
    var i = 0;
    do
    {
        i += 1;
        window.document.write("i=" + i + "<br>");
    }
    while (i < 3)
</script>我们
</body>
</html>

输出结果:
i=1
i=2
i=3
我们


详见:http://www.mark-to-win.com/index.html?content=Javascript/jsUrl.html&chapter=Javascript/js1_web.html#htmIntroJs

猜你喜欢

转载自blog.csdn.net/mark_to_win/article/details/82809657