所以我想旋轉一些文本片段與JavaScript順序。下面的代碼是隨機的,我的JavaScript是zilch。有人可以指導我如何使這個循環順序?謝謝!更改隨機Javascript的旋轉順序
網站建在Concrete5。 http://www.travelus.com.au/about-us/trial
<head>
<script type="text/javascript">
//messages keep each message on one line
var messages=new Array(
'message 1',
'message 2',
'message 3',
'message 4.'
)
//timer in seconds
var timer=5;
function firstMessage(){
newMessage()
setInterval ("newMessage()", timer*1000);
}
function newMessage()
{
var randno=Math.floor(Math.random()*(messages.length));
var elem =document.getElementById("msg");
elem.innerHTML = messages[randno];
}
</script>
</head>
<body onload="firstMessage()">
<div id="msg">There is supposed to be some content in this box, but you need Javascript to see it...</div>
</body>
工作就像一個魅力。 – Lime 2013-02-22 20:04:05