簡體   English   中英

如何使用javascript或html為我的網站制作一個跨瀏覽器友好的文本輪播?

[英]How can I make a text carousel for my site cross browser friendly by using javascript or html?

如何使用Javascript或html為我的網站提供跨瀏覽器友好的文本輪播? 我一直在努力使用下面的代碼,因為它只適用於Firefox,但它在IE上失敗了。 有沒有辦法可以讓它兼顧兩者?

<h4>Carousel-Text-Below </h4>

<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'    
type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function(){
function setRandomWord(){
    var phrases =new Array("1-Blah Text","2-Blah Text","3-Blah Text");  
    $("#test").text(phrases[Math.floor(Math.random()*phrases.length)]);
}
setInterval(setRandomWord,3000);
});
</script>
</head>
<body> 
<p style="border:1px dashed gray; background-color:white; padding: 10px">
<span id='test'>Blah Text-Text-Text</p>
</span> Guaranteed Service or...Text---Text</strong></p> 
</body> 
</html>

我認為這是因為你沒有設置doctype。 在這里嘗試過,它在<html>標簽前面與<!DOCTYPE html>一起使用。

也許IE被你的無效HTML搞糊塗了? 請注意,您要關閉<p>在關閉前<span>里面。 那么你最后也有無與倫比的</strong></p> 我相信你的意思是:

<p style="border:1px dashed gray; background-color:white; padding: 10px">
    <span id='test'>Blah Text-Text-Text</span>
    <strong>Guaranteed Service or...Text---Text</strong>
</p>

http://jsfiddle.net/xrS3t/

或者可能

<p style="border:1px dashed gray; background-color:white; padding: 10px">
    <span id='test'>Blah Text-Text-Text</span>
</p>
<p>
    <strong>Guaranteed Service or...Text---Text</strong>
</p>

http://jsfiddle.net/6nFVK/

我現在沒有IE測試,你能試試上面的jsfiddle鏈接嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM