Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post

    get parent element of control property

    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.

    Code:
    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

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When selection.type == "Control", a controlRange collection is returned -- which does not have a parentElement() method.

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

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    cheers! that worked!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •