/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] DOM scripting image maps

Hi,
can anyone tell me why this doesn’t work in IE6…

var myMap = document.createElement(“map”);
document.body.appendChild(myMap);
myMap.name = “myMap”;

var myArea = document.createElement(“area”);
myMap.appendChild(myArea);
myArea.shape = “rect”;
myArea.coords = “0,0,50,100”;
myArea.href = “http://www.google.com“;

var myImage = document.createElement(“img”);
document.body.appendChild(myImage);
myImage.src = “image.bmp”;
myImage.useMap = “#myMap”;

It works fine in Firefox.

thanks

Guy

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 30.2008 — var myMap;
try { //IE method
myMap = document.createElement('<map name="myMap">');
}
catch (error) { // DOM method
var myMap = document.createElement("map");
myMap.name = "myMap";
}
document.body.appendChild(myMap);

var myArea = document.createElement("area");
myMap.appendChild(myArea);
myArea.shape = "rect";
myArea.coords = "0,0,50,100";
myArea.href = "http://www.google.com";

var myImage = document.createElement("img");
document.body.appendChild(myImage);
myImage.src = "image.bmp";
myImage.useMap = "#myMap";

http://www.easy-reader.net/archives/2005/09/02/death-to-bad-dom-implementations/
Copy linkTweet thisAlerts:
@guy_murrayauthorMay 30.2008 — Many thanks for the prompt reply

The workaround works fine.

Guy
×

Success!

Help @guy_murray spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...