方式一:<标签名 οnclick=" javaScript diam" >不常用
<!DOCTYPE html>
<html>
<head>
<title>JavaScript嵌入的第一种方式</title>
</head>
<body>
<!--实现功能是,用户点击按钮时会弹出对话框
js是一门事件驱动器编程语言
鼠标实际:click
事件句柄:onclick
js的执行原理:在浏览器打开是不会运行
事件在发生的时候,js代码才会执行
--->
JavaScript的第一种嵌入方式:<P>
<!--
js弹窗的方式:window.alert("消息内容")
--->
<input type="button" value="欢迎" onclick="window.alert('hello js')"/>
<input type="button" value="欢迎" onclick="alert('hell javaScript');
alert('well com to study javaScript');
alert('go go !')
"/>
</body>
</html>
第二种方式;<script type="javascript/text" >代码块</script>
<!DOCTYPE html>
<html>
<head>
<title>javaScript使用的第二种方式</title>
<style type="text/css">
input{
size: 20;
border: 1px solid red;
}
</style>
</head>
<body>
javaScript嵌入的第二种方式 脚本块!<P>
<script type="text/javascript">
//javaScript脚本块 在脚本块种的代码,在页面打开的时候就会执行
//而且遵循自上而下的顺序
//脚本块在页面中可以出现多次,而且位置随意
window.alert('helllo word');
window.alert('helllo js');
</script>
<input type="button" value="欢迎" onclick="alert('我喜欢javaScript')">
</body>
</html>
第三种方式:<script type="javascript/text" src="xx.js”></script>
第三中方式:
<!DOCTYPE html>
<html>
<head>
<title>第三种方式</title>
</head>
<body>
<p>javaScript嵌入的第三中方式</p>
<script type="text/javascript" src="1.js"></script><P>
第二种方式:<P>
<script type="text/javascript">
window.alert('hello window');
</script><p>
第一种:
<input type="button" value="欢迎" onclick="window.alert('第三在方式')">
</body>
</html>