繁体   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