close

                                    
按鈕語法:
<input style="background: Color1width: npxheight: npx;" value="Text"onclick="body.style.backgroundColor='Color2';
 document.body.style.color='Color3';" type="button" />

background: Color1
==> 設定按鈕的背景顏色(最好與網頁背景色相同),
例如:background: white;  or  background: #FFFFFF;

body.style.backgroundColor='Color2'
==> 設定網頁的背景顏色,與 document.body.style.color 參數可並存或單獨設置,
例如:body.style.backgroundColor='black' or body.style.backgroundColor='#000000'

document.body.style.color='Color3'  
==> 設定網頁的文字顏色,與 body.style.backgroundColor 參數可並存或單獨設置,
例如:document.body.style.color='black' or document.body.style.color='#000000'

value="Text"    
==>設定按鈕的文字(可用來說明網頁背景或文字的新顏色,亦可不設置),
例如:value="白色"

width: npx; height: npx;
==> 設定按鈕的寬度與高度,同樣也可不設置,例如:width: 30px; height: 30px;

實際範例:
<input style="background: white;" value=" " onclick="body.style.backgroundColor='white';" type="button" />
<input style="background: #1e1e1e;" value=" " onclick="body.style.backgroundColor='#1e1e1e';" type="button" />
<input style="background: red;" value=" " onclick="body.style.backgroundColor='red';" type="button" />
<input style="background: blue;" value=" " onclick="body.style.backgroundColor='blue';" type="button" />
<input style="background: yellow;" value=" " onclick="body.style.backgroundColor='yellow';" type="button" />
<input style="background: green;" value=" " onclick="body.style.backgroundColor='green';" type="button" />
<input style="background: darkkhaki;" value=" " onclick="body.style.backgroundColor='darkkhaki';" type="button" />
<input style="background: darkviolet;" value=" " onclick="body.style.backgroundColor='darkviolet';" type="button" />
<input style="background: steelblue;" value=" " onclick="body.style.backgroundColor='steelblue';" type="button" />
<input style="background: silver;" value=" " onclick="body.style.backgroundColor='silver';" type="button" />

 

本文引用自tzoyiing - [部落格] 即時切換網頁背景/文字顏色的按鈕語法

arrow
arrow

    冰晨 發表在 痞客邦 留言(0) 人氣()