DOM & Passing reference of children to function

D

DaRik

Hello,

I'm putting together a menu with explorer like maps and I need to pass
a reference to the current node to another function that will change
the appearance of the map.

In the js I'm using DOM to build up the menu. I need to do something
like:

var mapnode = document.createElement('a');
mapnode.setAttribute("href", "javascript:eek:penMap(mapnode)");

but this code generates an error on the second line that mapnode isn't
defined (although it is just the line above).

'this' doesn't work either, so how can I submit the reference to the
function?

Another thing I thought of, was that if it was possible to retrieve
the position of the current node (for example body -> child 2 -> child
1 ) I would be able to find a reference to the node with something
like:

test = bodyNode.childNodes.item(2).childNodes.item(1)

Is this possible?

Thanks in advance

Rick
 
J

Jim Ley

var mapnode = document.createElement('a');
mapnode.setAttribute("href", "javascript:eek:penMap(mapnode)");

don't use javascript URI's on href's.

mapnode.onclick=function() { openMap(mapnode) }

Jim.
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top