.addEventListener('click', ...) on firefox 3

P

Pim

Hi,

I can't make this code work on *this* web client:
Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.13) Gecko/2009082121
Iceweasel/3.0.6 (Debian-3.0.6-1)


I want to add a 'click' event to an elem of this kind:
<div id="xx">taratata</div>, but this element is not
in the HTML file : it is "DOM created".

Here's what my code tries to do:

//Creating a <div id=fs>[< Agrandir >]</div>
var anewdiv = document.createElement('div');
anewdiv.id='fs';
anewdiv.innerHTML="[< Agrandir >]";

//Now inserting the Event handler on this div
var evType = 'click';
if (anewdiv.addEventListener){//Mozilla ¿ firefox ¿
alert("Mozilla");
anewdiv.addEventListener(evType, function() {alert("TEST!"); } , false);
return true;
}
else if (anewdiv.attachEvent){//IE
alert("IE");
var r =
anewdiv.addEventListerner( "on" + evType, function() { alert("TEST!");});
return r;
}
else {
alert("Impossible de brancher un gestionaire d'évènements");
return false;//branchement impossible
}

#Inserting element to the html page
var beforeElement = document.getElementById("topmenu");
var theParent = beforeElement.parentNode;
theParent.insertBefore(anewdiv, beforeElement);

The script works with IE (not it's not exactly this code for IE).
Firefox reports none errors and event handler seams to be inserted
,but when i click on the div area : nothing happens.
I cannot see errors in JS logs neithers.

Where dit i misstake?
Who can help me?

Thank's very much in advance.
 
P

Pim

Le 23 Nov 2009 21:08:58 GMT,

Subject closed: my div clicked zone was hidden by another div.

Thank you very much.
Pim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top