javascript thread: SV: Re: Adding a function as an event to an element node in IE 5.5 - 6
Joe,
With "using the table DOM", do you mean insertRow, insertCell etc?
(as in
http://www.w3.org/TR/2002/CR-DOM-Level-2-HTML-20021007/html.html#ID-6406
0425)
/Robert
-----Ursprungligt meddelande-----
Fr=E5n: Stefany StefanyBraverman [mailto:stefanybraverman@h...]
Skickat: den 31 oktober 2002 17:01
Till: javascript
=C4mne: [javascript] Re: Adding a function as an event to an element
node
in IE 5.5 - 6
do you have an example??
>From: "Joe Fawcett" <joefawcett@h...>
>Reply-To: "javascript" <javascript@p...>
>To: "javascript" <javascript@p...>
>Subject: [javascript] Re: Adding a function as an event to an element
>node
>in IE 5.5 - 6
>Date: Wed, 30 Oct 2002 17:10:28 +0000
>
>
>
>Firstly I think you should be creating tables using the Table dom but
>if
>your way is working stick with it..
>Although I haven't tried this I imagine that the reason is your table
row
>is trying to call a function that
>a) is in another window
>b) might not even exist when needed.
>If you can make the function part of the main window, if not possible
you
>will have to construct it on the fly but in the main window using the
dom
>to add a new script block.
>Joe
>
>
>
>
>>From: "stefany braverman" <stefanybraverman@h...>
>>Reply-To: "javascript" <javascript@p...>
>>To: "javascript" <javascript@p...>
>>Subject: [javascript] Re: Adding a function as an event to an element
>>node
>>in IE 5.5 - 6
>>Date: Wed, 30 Oct 2002 16:55:36
>>
>>Hi, I have been reading this tread very carefully because I have a
>>similar problem and need help
>>
>>I=92m creating a popup, the popup creates a dynamic table on the
parent
>>window and (This parts works fine)
>> I need to attach an event (onclick,onmouseove,onmouseout) to a
dynamic
>>row
>>Here is my code for the popup,
>>
>>var row
>>function myFunc(){
>>alert('hiho');
>>}
>>function sendValue(id,theform){
>>
>> var preval =3D window.opener.document.frmTemplate.H_name.value
>> if (preval =3D=3D ""){
>>
window.opener.document.frmTemplate.H_name.value=3Dwindow.document.fr
>>mTemplatePop.H_name.value;
>> }else{
>> var afterval=3D preval + "," +
>>window.document.frmTemplatePop.H_name.value
>> window.opener.document.frmTemplate.H_name.value=3Dafterval;
>> }
>>
>> var tbody =3D window.opener.document.getElementById
>>(id).getElementsByTagName("TBODY")[0];
>> row =3D window.opener.document.createElement("TR")
>> var td1 =3D window.opener.document.createElement("TD")
>> td1.appendChild(window.opener.document.createTextNode
>>(window.document.frmTemplatePop.H_name.value ))
>> var td2 =3D window.opener.document.createElement("TD")
>> td2.appendChild (window.opener.document.createTextNode
>>(window.document.frmTemplatePop.H_desc.value))
>> var td3 =3D window.opener.document.createElement("TD")
>> td3.appendChild (window.opener.document.createTextNode
>>(window.document.frmTemplatePop.H_date.value))
>> row.appendChild(td1);
>> row.appendChild(td2);
>> row.appendChild(td3);
>> tbody.appendChild(row);
>> row.id =3D"myrow";
>> row.style.fontFamily=3D"Aria";
>> row.style.fontSize=3D"8pt";
>>
>> row.attachEvent("onMouseOut",myFunc);
>> row.attachEvent("onclick",myFunc);
>> row.attachEvent("onmouseover",myFunc);
>> }
>></script>
>>
>>non of the event ever fires
>>Please help...
>>thank you
>>stefany
>>
>>
>> > Hi,
>>
>> > I've tried to dynamically bind events/functions to nodes under IE a
>> > few
>>w> ays and none seem to work. Here's the kind of thing I'm trying to
>>w> do:
>>
>> > <HTML>
>><> HEAD>
>><> SCRIPT>
>>
>> > function party(){
>> > alert("woo javascript party");
>>}>
>>
>> > function initParty()
>>{>
>> > aNode =3D document.createElement("a");
>> > aNode.setAttribute("onclick",party());
>> > aNode.setAttribute("href","javascript:void(0)");
>> > aNode.innerText =3D "click me";
>> > document.getElementById("test-div").appendChild(aNode);
>>
>> >
>>}>
>>
>> > </SCRIPT>
>><> /HEAD>
>><> BODY onload=3D"initParty()">
>> > <DIV ID=3D"test-div"></DIV>
>><> /BODY>
>><> /HTML>
>>
>> > If you try this code under IE, what will happen is, the function
>> > party
>>()
>>w> ill be called immediately (when
>>w> aNode.setAttribute("onclick",party())
>>l> ine is reached) instead of being called when bound to the onclick
>>event
>>f> or the <a> element.
>>
>> > Anyone know how to remedy this? To dynamically bind
>> > events/functions to
>>n> odes?
>>
>> > Cheers
>>
>> > Dan Schmierer
>>
>>---
>>
>>Improve your web design skills with these new books from Glasshaus.
>>
>>Usable Web Menus
>>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogra
m
>>me
>>r-20
>>Constructing Accessible Web Sites
>>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogra
m
me
>>r-20
>>Practical JavaScript for the Usable Web
>>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogra
m
me
>>r-20
>
>
>_________________________________________________________________
>Broadband?=A0Dial-up? Get reliable MSN Internet Access.
>http://resourcecenter.msn.com/access/plans/default.asp
>
>
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogram
m
>e
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogram
m
e
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogram
m
e
>r-20
>---
>Change your mail options at http://p2p.wrox.com/manager.asp or to
>unsubscribe send a blank email to
_________________________________________________________________
Surf the Web without missing calls! Get MSN Broadband.
http://resourcecenter.msn.com/access/plans/freeactivation.asp
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20