因此,我试图根据点击的图标更改背景,并且我不确定我的代码有什么问题!这只是一个测试页面(请原谅奇怪的代码,但我需要它在实际的网站本身!)单击图像时背景图像发生变化
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
body {
background: url('<?php echo $_GET['image']; ?>';
}
</style>
<script>
function showWeather(Weather) {
//alert(Weather);
myform.weather.value=Weather;
// alert(Weather);
// ._Weather
myform.submit();
}
</script>
<link href="teststyle.css" rel="stylesheet" type="text/css">
</head>
<body background="images/gradientsky.jpg">
<div id="weather">
<ul id="nav-reflection">
<form method="post" action="cloudy_name.php" id="myform">
<li class="button-color-1"><a href="cloudy_name.php?image=images/cloudysky.png" onclick="showWeather('cloudy');" title="My fancy link"><img src="images/cloudybubble.png" width="211" height="180" align="left"></a></li>
<input type="hidden" name="weather" value="whatever">
</form>
</ul>
</div>
</body>
</html>
你要改变目标页面的BG? – chepe263 2012-04-20 19:54:16
是的,目的地页面的背景被改变了,那个页面正在变为cloudy_name.php – 2012-04-20 19:57:16
由于您使用'window.location'进行重定向,因此您无法在目标页面中更改样式。另外,当你调用'getElementById'时,你应该在“test”周围加引号。 – 2012-04-20 19:57:27