JavaScript instance basis

Generating text
<html>
<body>

<script type="text/javascript">
document.write("Hello World!")
</script>

</body>
</html>

Generating plain text and labels  
<html>
<body>

<script type="text/javascript">
document.write("<h1>Hello World!</h1>")
</script>

</body>
</html>

head part
<html>
<head>
<script type="text/javascript">
function message()
{
alert("该提示框是通过 onload 事件调用的。")
}
</script>
</head>

<body onload="message()">

</body>
</html>

body part
<html>
<head>
</head>

<body>

<script type="text/javascript">
document.write("该消息在页面加载时输出。")
</script>

</body>
</html>

External JavaScript
<html>
<head>
</head>
<body>

<script src="../js/example_externaljs.js" tppabs="http://www.w3school.com.cn/js/example_externaljs.js">
</script>

<p>
实际的脚本位于名为 "xxx.js" 的外部脚本中。
</p>

</body>
</html>

Reproduced in: https: //my.oschina.net/u/2552902/blog/543959

Guess you like

Origin blog.csdn.net/weixin_33928467/article/details/92326551