Nick LaMarca
Nick LaMarca

Reputation: 8188

Not Triggering OnClick Event IE8 but Works Fine In Firefox

  var hyp = document.createElement("a");
  //hyp.style.cssText='cursor:pointer';
  hyp.onclick="RemoveDv('" + divid + "');";    
  hyp.innerHTML = "Remove";

I have javascript with this code snippit in there. In firefox everything works fine but in IE8 it works fine if I run it locally, but uploading the code to a server and running through my same IE8 browser that I ran it locally the RemoveDv event will NOT fire.

This is the html created from this javascript

<a style="cursor: pointer;" onclick="RemoveDv('dv1');">

Upvotes: 0

Views: 578

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

onclick should be a function, not a string.

hyp.onclick = function() {RemoveDv(divid);};

EDIT: Hey, this is my 2,000th answer!

Upvotes: 5

Related Questions