html中JavaScript函数参数传递--传字符串

该小程序中,自定义函数参数传递为字符串格式时,下面自写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>

你可能感兴趣的:(JavaScript,java,html)