473,408 Members | 2,832 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,408 software developers and data experts.

Trying to Find the ParentNode

I am trying to get all the "polyline" tags and then find the parent node
above it so I can transform it.

var poly = svgDocument.getElementsByTagName("polyline");
for ( var i=0; i < poly.length; i++ )
{
myobj=poly.parentNode(i);
alert(i + myobj);
}

This is not working. Any help is appreciated.

Mike

Jul 20 '05 #1
3 1907
"Michael Hill" <hi****@ram.lmtas.lmco.com> wrote in message
news:40***************@ram.lmtas.lmco.com...
I am trying to get all the "polyline" tags and then find the
parent node above it so I can transform it.

var poly = svgDocument.getElementsByTagName("polyline");
I haven't had much to do with scripting the SVG DOM yet, but:-
for ( var i=0; i < poly.length; i++ )
{
myobj=poly.parentNode(i);
In principal - poly - is a nodeList interface implementing object. In
JavaScript/ECMA Script it should be posible to access numerically
indexed members of a nodeList in the same way as an Array is accessed;-
poly[i] - or using the nodeList's - item - method - poly.item(i) - .
That should return a reference to one of the "polyline" elements. It is
those elements that may/should have a parentNode property, not the
nodeList object.

The object that represents the parentNode (if any) would be another
element and almost certainly implemented as an object, not a function.
So calling that property and passing - i - as a parameter to that
function call doesn't make much sense. Probably you want something
like:-

myobj = poly[i].parentNode;

alert(i + myobj);
If - i - is an integer and - myobj - refers to an object what do you
expect to be the result of adding them together? You can type-convert
them to strings and get the - + - operator to do concatenation by adding
a string to that expression:-

alert( i + " " + myobj);

The result should also be clearer to read, as it will introduce a space
between them.
}

This is not working. Any help is appreciated.


"This is not working" is rarely sufficient information to allow anyone
to usefully comment on why something isn't working. You need, at the
very least, to provide a context (testing/execution environment(s)) for
it and some criteria for "working" and details of how failure to achieve
that is manifesting itself. Particularly important are any error
messages generated.

Richard.
Jul 20 '05 #2
On Thu, 15 Jan 2004 04:47:12 -0000, "Richard Cornford"
<Ri*****@litotes.demon.co.uk> wrote:
"Michael Hill" <hi****@ram.lmtas.lmco.com> wrote in message
news:40***************@ram.lmtas.lmco.com...
I am trying to get all the "polyline" tags and then find the
parent node above it so I can transform it.

var poly = svgDocument.getElementsByTagName("polyline");
I haven't had much to do with scripting the SVG DOM yet, but:-


It's nice! You've got DOM 2,
JScript, JavaScript (both rhino and spidermonkey) and KJS are all
used by good SVG user agents, although it's a time when using the
Compact Profile (ECMA 327 is it? - this could be FAQ'd actually?) as
there are a lot of scriptable mobile user agents.

There is an old SVG browser (ASV 2 in NN4) that doesn't have try/catch
but all others do and you're probably safe to use it.
myobj = poly[i].parentNode;


Yep!

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

Jul 20 '05 #3
"Jim Ley" <ji*@jibbering.com> wrote in message
news:40***************@news.cis.dfn.de...
<snip>
I haven't had much to do with scripting the SVG DOM yet, but:-


It's nice! You've got DOM 2, JScript, JavaScript
(both rhino and spidermonkey) and KJS are all used
by good SVG user agents, although it's a time when
using the Compact Profile (ECMA 327 is it? - this
could be FAQ'd actually?) as there are a lot of
scriptable mobile user agents.

<snip>

Yes, ECMA 327 is the Compact Profile and it probably does deserve a
mention in the FAQ. Especially as it is only two pages on the features
from ECMA 262 that do not need to be implemented in the Compact Profile.

Richard.
Jul 20 '05 #4

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

Similar topics

8
by: jklimek | last post by:
I have something like this: <table name="test" id="test"> <tr> <td><input type="button" onClick="showMeParentTableName();"></td> </tr> </table> How can I have my input button show me the...
3
by: ningjun.wang | last post by:
Hello: My html file contains the following image link: <a href="some_url"><img src="MyImage.gif"></a> How can I use Javascript to find out the value of some_url for the given image name...
2
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
2
by: amattie | last post by:
Anyone know what the specific difference is between the offsetParent and parentNode properties of a DOM element are? Mozilla's docs on the DOM element...
7
by: webdeveloper | last post by:
Without showing any code, I thought maybe somebody already knows what the error message in the title generally means? But in short, a menu is supposed to display by setting its inline style...
0
by: jiing | last post by:
Hi all, I want to use sting(the same as Node.Text) to judge if a node exists in TreeView. I've tried several ways, but seems all failed. could anybody help me? Thanks in advance. //My...
3
by: gouthami | last post by:
I have a tree Node in my application and i have set the following code in the NavigateUrl property of the tree node. Please see my code below (which is present in my 'code behind' c# file). My...
2
by: bent27 | last post by:
I'm new to javascript...I'm getting 'parentNode' is null or not an object error in the following code for (var ci=0;ci<headerLink.parentNode.childNodes.length;ci++) { if...
3
XtinaS
by: XtinaS | last post by:
I'm trying to write a script for Greasemonkey that will, in LiveJournal, replace a placeholdered embedded YouTube thing with a link to the video. In LiveJournal, you can set an option to have a...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.