不积跬步,无以至千里

博客园 首页 新随笔 联系 订阅 管理

该小程序中,自定义函数参数传递为字符串格式时,下面自写3种方法:
①:采用this传递
②:引号缺省
③:转义字符(html中 &quot 代表"双引号,JScript中直接\" 和Java通用转义字符集)

<html>
<head>
    <script language="LiveScript">
         function pushbutton(arg){
             alert("嗨!你好, "+arg);
    }
</script>
</head>
<body>
<form>
   <input type="button" name="Button1" value="Push me" onclick="pushbutton(this.str)" str="宇熙">
  <br><br>
  <input type="button" name="button2" value="clicl me" onclick=pushbutton("俊基")>

<br><br>
  <input type="button" name="Third" value="Third" onclick="pushbutton (&quot卡哇伊&quot)">

  </form>
</body>
</html>

posted on 2016-12-15 12:21  Zeroassetsor  阅读(1249)  评论(0)    收藏  举报