|
 |
javascript thread: Re: Adding a function as an event to an element node in IE 5.5 - 6
Message #1 by "stefany braverman" <stefanybraverman@h...> on Wed, 30 Oct 2002 16:55:36
|
|
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?m 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 = window.opener.document.frmTemplate.H_name.value
>> if (preval == ""){
>> window.opener.document.frmTemplate.H_name.value=window.document.fr
>>mTemplatePop.H_name.value;
>> }else{
>> var afterval= preval + "," +
>>window.document.frmTemplatePop.H_name.value
>> window.opener.document.frmTemplate.H_name.value=afterval;
>> }
>>
>> var tbody = window.opener.document.getElementById
>>(id).getElementsByTagName("TBODY")[0];
>> row = window.opener.document.createElement("TR")
>> var td1 = window.opener.document.createElement("TD")
>> td1.appendChild(window.opener.document.createTextNode
>>(window.document.frmTemplatePop.H_name.value ))
>> var td2 = window.opener.document.createElement("TD")
>> td2.appendChild (window.opener.document.createTextNode
>>(window.document.frmTemplatePop.H_desc.value))
>> var td3 = 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 ="myrow";
>> row.style.fontFamily="Aria";
>> row.style.fontSize="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 do:
>>
>> > <HTML>
>><> HEAD>
>><> SCRIPT>
>>
>> > function party(){
>> > alert("woo javascript party");
>>}>
>>
>> > function initParty()
>>{>
>> > aNode = document.createElement("a");
>> > aNode.setAttribute("onclick",party());
>> > aNode.setAttribute("href","javascript:void(0)");
>> > aNode.innerText = "click me";
>> > document.getElementById("test-div").appendChild(aNode);
>>
>> >
>>}>
>>
>> > </SCRIPT>
>><> /HEAD>
>><> BODY onload="initParty()">
>> > <DIV ID="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 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=nosim/theprogramme
>>r-20
>>Constructing Accessible Web Sites
>>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>>r-20
>>Practical JavaScript for the Usable Web
>>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>>r-20
>
>
>_________________________________________________________________
>Broadband? Dial-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=nosim/theprogramme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
>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
|
|
 |