View Full Version : Trouble placing html image map in external JS file

Remon Jones
09-21-2005, 06:51 AM

I have created an html image map that I would like to have appear on multiple Web pages; therefore, I would like to place the html instructions inside document.write commands in a js file. I have had no trouble in the past when it comes to getting external js files to perform using document.write commands; I often use js files to supply a consistent navigation area, for instance; however, I can't seem to make my image map work when I call it up from an external file. (The image map works fine when its coding is on the html page itself.)

Below is an abbreviated version of the js file I am using so that hopefully someone can tell me what I'm doing wrong. The file name is test.js and the script is "called" in the body section of my html page with the line

<SCRIPT SRC="test.js" TYPE="text/javascript">

abbreviated version of external file test.js.........

document.write ('<MAP NAME="owlalleyMap4">');
document.write ('<AREA SHAPE="polygon" COORDS="65,138,94,126,110,161,115,187,82,185,80,204,67,202" HREF="mailto:quass@quass.com" TITLE="E-mail owlmaster Brian">');
document.write ('<IMG SRC="http://www.quass.com/owlspecies/owlalley.jpg" WIDTH="681" HEIGHT="369" ALIGN="BOTTOM" BORDER="0" USEMAP="#owlalleyMap4">');

Thanks for any and all help,

09-22-2005, 05:13 PM
I assume the js file is large one. Which browser do you use?

Remon Jones
09-23-2005, 07:11 AM
I use Safari 1.3.1 and I.E. 5.2 for Mac, neither of which will display my image map from a js file.

I've uploaded the functioning html version of the image map to my site at


You're welcome to look at the source code there. I thought transferring the image map coding to a separate js file was just a matter of putting the map and area statements inside document.write(" ") brackets, but that doesn't seem to work.

Thanks again for your time.


09-23-2005, 07:53 AM
Why are you trying to put the image map in a JS file in the first place? You can use a server side include if all you intend to do is write the image map to the page.

Remon Jones
09-23-2005, 04:32 PM
I don't know how to use a server side include and my hosting company provides no assistance for such things.

09-24-2005, 04:31 AM
did you try something like:

function drawMap() {

and in html
<SCRIPT SRC="test.js" TYPE="text/javascript">

09-24-2005, 07:02 AM
Probably a stupid question but,

Why not do this for every page?

<iframe src="http://www.quass.com/example.html" style="width:681;height:369;margin:0 0 0 0;" Allowtransparency ="True"></iframe>