所以我试图用javascript顺序旋转一些文本片段。下面的代码是随机的,我的 javascript 是 zilch。有人可以指导我如何使这种轮换顺序吗?谢谢!
网站建在 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>