<!DOCTYPE?HTML>
<html>
????<head>
????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gd2312">
????????<title>制作我的第一個(gè)網(wǎng)頁</title>
????</head>
????<body>
????????<h1>標(biāo)題1</h1>
?????
????????<script?language="javascript">
????????????????????????<form?name="name1"method="post"?action="">
?????????<input?name="submit"type="button"value="更換背景顏色"onclick="turncolour();"><!--這是插入一個(gè)按鍵-->
???????
???????????</form>
????????var?arraycolour=new?Array("olive","teal","red","blue","maroon","green","yellow");????<!--定義一個(gè)顏色數(shù)組-->
????????var?n=0;
????????function?turncolour()?????????????????????????????????????????????????????????<!--函數(shù)完成顏色變換-->???????????????????????????????????????
????????{
????????if(n==(arraycolour.length-1))?n=1;
????????n++;
????????document.bgColor=arraycolour[n];
?????????}
????????</script>
????</body>
</html>

2017-09-15
是不是實(shí)現(xiàn)變色啊!你把form的寫在<script></script>中了,把他放在外面就可以了!
<!DOCTYPE?HTML>
<html>
????<head>
????????<meta?http-equiv="Content-Type"?content="text/html;?charset=gd2312">
????????<title>制作我的第一個(gè)網(wǎng)頁</title>
????</head>
????<body>
????????<h1>標(biāo)題1</h1>
? ? ? ? ?<form?name="name1"method="post"?action="">
?????????<input?name="submit"type="button"value="更換背景顏色"onclick="turncolour();"><!--這是插入一個(gè)按鍵-->
? ? ? ? </form>
????????<script?language="javascript">
????????var?arraycolour=new?Array("olive","teal","red","blue","maroon","green","yellow");????<!--定義一個(gè)顏色數(shù)組-->
????????var?n=0;
????????function?turncolour()?????????????????????????????????????????????????????????<!--函數(shù)完成顏色變換-->???????????????????????????????????????
????????{
????????if(n==(arraycolour.length-1))?n=1;
????????n++;
????????document.bgColor=arraycolour[n];
?????????}
????????</script>
????</body>
</html>
2017-09-15
你的告訴別人要實(shí)現(xiàn)什么