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
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy JavaScript: WYSIWYG Editor... Object selection, Mozilla

    Hello, I'am building a wysiwyg editor and I have trouble to detect an object like a TABLE, an IMAGE etc...
    I found this method but it only works with MSIE...
    Is there a way to do the same thing in MOZILLA ???

    Here is my code...


    if (this.myEditor.document.selection.type == 'Control')
    {
    var range = this.myEditor.document.selection.createRange();
    // Check if one object is selected
    if (range.length == 1 && (range(0).tagName == 'TABLE' || range(0).tagName == 'table'))
    {
    current_width=range(0).width;
    current_height=range(0).height;
    current_border=range(0).border;
    current_bordercolor=range(0).borderColor;
    current_cellspacing=range(0).cellSpacing;
    current_cellpadding=range(0).cellPadding;
    current_align=range(0).align;
    current_bgcolor=range(0).bgColor;
    alert (current_width);
    // alert other variables to view...
    return true;
    }
    }

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    there might be getSelection() method... I read about it but never used or tested it...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Microsoft made their own text ranges and selection mechanism. Mozilla uses the standard one. See <http://www.mozilla.org/docs/dom/domr...range_ref.html> for ranges, <http://www.mozilla.org/docs/dom/domr...4.html#1000044> for the window.getSelection method, and <http://unstable.elemental.com/mozill...n-members.html> for the Selection object.

    The best resource explaining these concepts is sadly no longer online, but I've found a cached version of it in the wayback machine <http://web.archive.org/web/200307240...ct_Article.htm>. Beware that this page might disappear at any time, though.
    Last edited by liorean; 11-08-2004 at 02:57 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

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