You can achieve this by using JavaScript in two ways:
(1) Whenever the user clicks on the links you can invoke a JavaScript function that know which image needs to be loaded and change the background image of the div you want. The following example demonstrate this one.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
#test {
width: 750px;
border: 1px dotted #ff0000;
height: 300px;
}
</style>
<script type="text/javascript">
function changeDivBGround(imgName) {
document.getElementById('test').style.backgroundImage = "url("+imgName+")";
}
</script>
</head>
<body>
<p>
<a href="#" onclick="changeDivBGround('tables2tabs.jpg'); return false;">link 1</a> <br />
<a href="#" onclick="changeDivBGround('tabletabs.gif'); return false;">link 1</a>
</p>
<div id="test"></div>
</body>
</html>
* If the images are not in the same folder of your html page make sure that you are passing the path also along with the image name.
(2) In this method you'll have different style classes in your CSS say for example each link has their own style with the background image you want to load in the div element. Whenever the user clicks on the links you'll change the div's class using JavaScript something like the following code:
Code:
function changeDivBGround(linkId) {
var obj = document.getElementById('test');
obj.className = linkId +'_class';
}
The assumption in this case is we'll have class names based on the link IDs we mention in the hyperlinks say for example if the first link has a id 'first_link' then the style needs to be applied on the div would be 'first_link_class'.
Bookmarks