為什么都不彈出來?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我們互動下</title>
<script type = "text/javascript">
? ? function.window(){
? ? ? ? document.write("JS進階篇");
? ? ? ? alert("關注JS高級篇");
? ? }
</script>
</head>
<body>
? ? <input name="button" type="button" onclick="window()" value="點擊我,彈出對話框" />
</body>
</html>
2017-08-10
? ? function.window() 這里function后面多了個 (.)點
2017-08-14
函數(shù)定義語法 function 函數(shù)(){.....}
另,函數(shù)名不能用html關鍵字(不能用window、top、button、標簽名啊……等類似這些)
所以,可以寫成下面這樣
?function mytext(){
? ? ? ? document.write("JS進階篇");
? ? ? ? alert("關注JS高級篇");
? ? }
</script>
</head>
<body>
? ? <input name="button" type="button" onclick="mytext()" value="點擊我,彈出對話框" />
</body>
</html>
2017-08-10
function.window(){ ? ? 換成 ? ?function window(){