1.初级方案
<input type="button" value="显示效果" onclick="alert('我被点了')" />
2.中级方案
<script>  function f1() {    alert("这是一个对话框");  }</script><input type="button" value="显示效果" onclick="f1()"/>
3.最终方案:使用dom对象进行事件分配
<input type="button" value="开始分离代码" id="btn1" />//  //根据id属性的值从整个文档中获取这个元素(标签)var btnObj1=document.getElementById("btn1");  //为该元素注册点击事件btnObj1.onclick=function () {    alert("哦,这真是太好了");};//根据id属性的值从整个文档中获取这个元素(标签)//为该元素注册点击事件document.getElementById("btn1").onclick=function () {  alert("哦,这真是太好了");};//注意  : <script>标签在body前后位置带来的影响