好吧,我在網上看到過很多這方面的問題,但似乎很多問題都在使用PHP,ASP,JQUERY和其他語言。對於我來說,我只對CSS和Java Script有點熟悉,那是我只知道的語言。那麼有人可以向我展示一些關於CSS和Java Script的代碼嗎?如何每次點擊每個鏈接或網址時更改我網站的背景圖片?
無論如何,我也有興趣在網站上的背景,將改變每一個刷新!
在此先感謝!
嘿,我發現了示例代碼,它是完美的工作!
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function changeImg(imgNumber) {
var myImages = ["Background/Background.jpg", "Background/Background2.jpg", "Background/Background3.jpg", "Background/Background4.jpg", "Background/Background5", "Background/Background6", "Background/Background7"];
var imgShown = document.body.style.backgroundImage;
var newImgNumber =Math.floor(Math.random()*myImages.length);
document.body.style.backgroundImage = 'url('+myImages[newImgNumber]+')';
}
window.onload=changeImg;
</script>
<style type="text/css">
.bg {background-attachment:fixed; background-repeat: no-repeat; background-position:top right;}
</style>
</head>
<body class="bg">
<p>Some text</p>
<!-- put a lot text lines here to see that the background stays fixed. -->
<p>Some text</p>
</body>
</html>
[你嘗試過什麼?](http://www.whathaveyoutried.com/) –
如果使用刷新一個新的形象,每次,比你殺死你的網站美+你討厭你的用戶通過增加頁面加載時間 –
嗨! Alien先生我的網站通過局域網運行,我的意思是它在共享網絡或計算機內運行。 :D所以基本上頁面加載不是一個問題。這就是我對這項工作感興趣的原因。 – Jayseer