用以增加新鮮感,每次更改原程碼標頭相片地址,覺得不便,於是索性為選定幾張標頭相片,寫個小程式將相片隨機載入,每刷新(refresh)一次網誌,標頭相片便隨機載入。
小程式原程碼放在網誌原碼<body>下﹕
<script type="text/javascript">
var banner= new Array()
banner[0]="圖片網址"
banner[1]="圖片網址"
banner[2]="圖片網址"
banner[3]="圖片網址"
var random=Math.floor(banner.length*Math.random());
document.write("<style>");
document.write("#header-wrapper {");
document.write(' background:url("' + banner[random] + '") no-repeat center;');
document.write(" }");
document.write("</style>");
</script>有興趣者推介一試。
沒有留言:
發佈留言