contxt()加不加function的區(qū)別??
如果在contxt()不加function,則會(huì)直接彈出alert警告框了, 如果加了function則不會(huì),必須是點(diǎn)擊了onlick后才有會(huì)彈框!
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>函數(shù)調(diào)用</title> ???<script?type="text/javascript"> ?????contxt()?//定義函數(shù) ??????{ ?????????alert("哈哈,調(diào)用函數(shù)了!"); ??????} ???</script> </head> <body> ???<form> ??????<input?type="button"??value="點(diǎn)擊我"?onclick="?contxt()???"?/>?? ???</form> </body> </html>
2016-07-01
??我試了你的代碼,沒有反應(yīng),應(yīng)該是瀏覽器的問題
2016-06-16
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數(shù)調(diào)用</title>
? ?<script type="text/javascript">
? ? ?contxt() //定義函數(shù)
? ? ? {
? ? ? ? ?confirm("哈哈,調(diào)用函數(shù)了!");
? ? ? }
? ?</script>
</head>
<body>
? ?<form>
? ? ? <input type="button" ?value="點(diǎn)擊我" onclick=" contxt() ? " /> ?
? ?</form>
</body>
</html>