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