/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Problem with image onclick in IE

Hi, i have a problem again

Note: I’ve searched the forum for a solution with no luck;

I am dynamically creating images in a table with javascript, assigning each image an id and an onclick event. like this

image = document.createElement(“img”);
image.style.width = “160px”;
image.style.height = “120px”;
image.src = source;
image.alt = alternate;
image.setAttribute(“id”, “image”+itt);
image.setAttribute(“onclick”, “test(this.id)”);

Now this works fine in Firefox (the onclick is recognized and the function is executed) but in IE, the onclick won’t fire, as if it’s not recognized.

As a side note: using: image.onclick = “test(this.id)” doesn’t work in either Firefox or IE

Any help would be greatly appreciated

Thank you

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayMar 14.2008 — Try this:

<i>
</i>image.onclick = function () { test(this.id) };
Copy linkTweet thisAlerts:
@KyuuzoauthorMar 14.2008 — Thanks a lot. That fixed my problem. I learn something new about javascript everyday (new to it and ASP also)

Cheers
×

Success!

Help @Kyuuzo 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.10,
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,
)...