Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to swap images in an Images map... Get: document.map is null...

Status
Not open for further replies.

grahamcr

Technical User
Jan 23, 2006
7
CA
Hi I have the following script in my header:
Code:
<script type="text/javascript">
        var path = 'Images/';
	var imgObj = new Image();
	var imgs = Array('index.jpg','sheet01.jpg');
	for(i=0;i<imgs.length;i++)
		{imgObj.src=path+imgs[i];}
	function swap(src)
	        {document.map.src=path+src;}
</script>

Then in my image map I call...

Code:
<area shape="rect" coords="27,53,115,123" href="Maps/Far_North_lambert_sheet1.pdf"  alt="Sheet 1" title="Sheet 1" onmouseover="swap('sheet01.jpg');" onmouseout="swap('index.jpg');">

When I hover over the area I get an error:
"'document.map' is null or not an object"

The error is pointing to the line:
{document.map.src=path+src;}

What do I have to do to set this?

Any help extremely appreciated.
 
Give your image map an id of map and then use something like:
Code:
function swap(src)
{
document.getElementById('map').src=path+src;
}
At present, you don't show an image named "map", so I can't tell if that's the problem or not.

Lee
 
Lee,
thanks very much that was it indeed. The image name was something else, but I cant believe I messed that up.... sigh...

Take care,
Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top