473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DOM & Passing reference of children to function

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:openMap(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
Jul 23 '05 #1
1 1237
On 1 Jun 2004 07:42:24 -0700, bo**********@hotmail.com (DaRik) wrote:

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


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

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

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Sleeman | last post by:
Hi all, i just spent an hour rifling through code to find the cause of a problem only to find it's an oddity with serialization and recursive objects, so figured I'd post for the next person who...
12
by: sathia | last post by:
Hi, I have this table:   CREATE TABLE `osservatorio` (   `id` int(10) unsigned NOT NULL auto_increment,   `testo` varchar(255) NOT NULL default '',   `parent` int(11) default NULL,...
12
by: Andrew Edwards | last post by:
Gentlemen, I have a Binary Search Tree ADT that should use recursion for all operation except for isEmpty() and isFull(); I have completed the insert function, and after inserting the numbers...
6
by: Otto Wyss | last post by:
I've the following function declaration: wxTree GetLastChild (const wxTree& item, long& cookie) const; I'd like to make the cookie parameter optional, i.e. "long& cookie = ....", without...
11
by: modemer | last post by:
If I define the following codes: void f(const MyClass & in) {cout << "f(const)\n";} void f(MyClass in) {cout<<"f()\n";} MyClass myclass; f(myclass); Compiler complain that it can't find...
25
by: Victor Bazarov | last post by:
In the project I'm maintaining I've seen two distinct techniques used for returning an object from a function. One is AType function(AType const& arg) { AType retval(arg); // or default...
8
by: toton | last post by:
HI, One more small doubt from today's mail. I have certain function which returns a pointer (sometimes a const pointer from a const member function). And certain member function needs reference...
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
4
by: 9lives.9lives | last post by:
Hello, everyone! I am trying to optimize some code, but I don't think I'm doing what I think I'm doing. I profiled my code and found that the overloaded operator of my monomial class did...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.