在小程序中,自定義函數參數傳遞爲字符串格式時,下面自寫3種方法:
①:採用this傳遞
②:引號缺省
③:轉義字符(html中 " 表明"雙引號,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 ("字符串")">
</form>
</body>
</html>html