我在JQuery(JavaScript)中有以下代碼,並且在Chrome,Safari和Firefox中正常工作。但是,它不會在Internet Explorer 8中顯示它們。可能有哪些錯誤?我使用960gs作爲CSS框架。JQuery/CSS與Internet Explorer 8不顯示背景圖像
// JavaScript
var site_root = "http://localhost:8080";
var banner = new Array();
banner[1] = site_root + "/images/banner-1.png";
banner[2] = site_root + "/images/banner-2.png";
banner[3] = site_root + "/images/banner-3.png";
banner[4] = site_root + "/images/banner-4.png";
banner[5] = site_root + "/images/banner-5.png";
banner[6] = site_root + "/images/banner-6.png";
var counter = 1;
$(document).ready(function() {
$('#top_banner').hide();
$('#top_banner').slideDown('slow');
var timer = setInterval(StepThroughBanners, 5000);
function StepThroughBanners() {
var link = "url(" + banner[counter] + ")";
$('#top_banner').css("background-image", link);
if(counter<6) {
counter++;
} else {
counter = 1;
}
}
});
這裏是我的CSS:
#top_banner {
background: #fff;
background-image: url("../images/banner-1.png");
background-repeat:no-repeat;
color: #fff;
height: 370px;
padding: 1em;
}
編輯:(HTML加)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head><title><?= $title ?></title>
<!-- load style framework 960 -->
<link rel="stylesheet" type="text/css" href="<?= base_url(); ?>css/960.css" />
<link rel="stylesheet" type="text/css" href="<?= base_url(); ?>css/reset.css" />
<link rel="stylesheet" type="text/css" href="<?= base_url(); ?>css/text.css" />
<!-- load custom styles -->
<link rel="stylesheet" type="text/css" href="<?= base_url(); ?>css/custom.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?= base_url();?>scripts/general.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="container_16">
<div id="top_menu" class="grid_16">
<div class="menu">
<ul>
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
<li><a href="#">item 5</a></li>
<li><a href="#">item 6</a></li>
</ul>
</div>
<div class="tool">
<ul>
<li><a href="#">one ▾</a></li>
<li><a href="#">two ▾</a></li>
<li><a href="#">three ▾</a></li>
</ul>
</div>
<div class="search">
<form>
<input type="text" value="search..."></input>
</form>
</div>
</div>
<div class="clear"></div>
<div id="top_banner" class="grid_16"> </div>
<div class="clear"></div>
<div class="grid_4 mockup">460px</div>
<div class="grid_4 mockup"><p>460px</p></div>
<div class="grid_4 mockup"><p>460px</p></div>
<div class="grid_4 mockup">460px</div>
<div class="clear"></div>
</div>
</body>
</html>
你可以發表你的HTML嗎? – T9b 2011-06-14 12:45:05
非常感謝大家的幫助... facepalm--我在Windows系統上測試了這個網站 - 在我的家庭網絡上... site_root,你可以猜到...是的,我應該得到火災利益。 :( – Shyam 2011-06-14 14:20:24