...

View Full Version : get parent element of control property



homerUK
05-09-2004, 02:41 PM
Hey,
I already have the code to get the parent element of basic text inside an iFrame, but the code doesnt work when you select a control element, for example an image or input text box.

here's the code I have which gets the parent element and builds an HTML path of the cursor element.



var cursor = iView.document.selection.createRange();
var element = cursor.parentElement();

while (element.nodeName.toUpperCase() != "HTML") {
//go through the elements and build the path
path += "<" + element.nodeName + ">";
if (element.parentNode) {
element = element.parentNode;
}
}


The error message I get in JS is

"object doesnt support this property or method"

any help is much appreciated.
thanks :D

swmr
05-10-2004, 03:10 AM
When selection.type == "Control", a controlRange (http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/controlrange.asp) collection is returned -- which does not have a parentElement() method.

- in that case it would be something like cursor(0).parentElement;

homerUK
05-10-2004, 11:44 AM
cheers! that worked! :D :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum