TonyJollans
Programmer
I really haven't got a proper grip on this, so I may be doing stupid things or asking stupid questions so I apologise in advance if that is the case, and if it is, do please tell me.
I have some constructs like this:
[tt] <A HRef = "Team.htm">
<IMG ID = "ButTm" Class = "Button">
</A>[/tt]
And I have JavaScript code which runs in the page's OnLoad event and loops through the images and does a few things. What I am struggling with is dynamically assigning the code I want to the IMG's parent A tag's mouseover event and having this code pass a reference to the child IMG tag's id. I can do it like this:
[tt] document.images.parentNode.onmouseover = function() {myFunc(this.childNodes[[highlight]0[/highlight]].id);};[/tt] in IE, or
[tt] document.images.parentNode.onmouseover = function() {myFunc(this.childNodes[[highlight]1[/highlight]].id);};[/tt] in Firefox
The difference is because of the way the different browsers assign Nodes to whitespace, and I want to do it like this:
[tt] document.images.parentNode.onmouseover = function() {myFunc(this.childNodes[[highlight]j[/highlight]].id);};[/tt] in all browsers.
I have code which checks and assigns the correct value to my variable, j. I can't, however, assign the value of j to the event code because everything to the right of the equals sign is taken as literal text. This means that the variable j itself is included in the code assigned to the event rather than its value, and its value at event time is passed to the event instead of its value at assignment time.
I have got round it by putting extra code in the assigned function, myFunc, but don't like having to do it that way and would like to properly understand what I'm working with. How can I code it so that the j is translated 'up front'?
Enjoy,
Tony
--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
I have some constructs like this:
[tt] <A HRef = "Team.htm">
<IMG ID = "ButTm" Class = "Button">
</A>[/tt]
And I have JavaScript code which runs in the page's OnLoad event and loops through the images and does a few things. What I am struggling with is dynamically assigning the code I want to the IMG's parent A tag's mouseover event and having this code pass a reference to the child IMG tag's id. I can do it like this:
[tt] document.images.parentNode.onmouseover = function() {myFunc(this.childNodes[[highlight]0[/highlight]].id);};[/tt] in IE, or
[tt] document.images.parentNode.onmouseover = function() {myFunc(this.childNodes[[highlight]1[/highlight]].id);};[/tt] in Firefox
The difference is because of the way the different browsers assign Nodes to whitespace, and I want to do it like this:
[tt] document.images.parentNode.onmouseover = function() {myFunc(this.childNodes[[highlight]j[/highlight]].id);};[/tt] in all browsers.
I have code which checks and assigns the correct value to my variable, j. I can't, however, assign the value of j to the event code because everything to the right of the equals sign is taken as literal text. This means that the variable j itself is included in the code assigned to the event rather than its value, and its value at event time is passed to the event instead of its value at assignment time.
I have got round it by putting extra code in the assigned function, myFunc, but don't like having to do it that way and would like to properly understand what I'm working with. How can I code it so that the j is translated 'up front'?
Enjoy,
Tony
--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[