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 4 of 4
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    execCommand clear all formating

    sample text:

    chfjgj ghj gfhj hg jgfh jfg foo sdčlfaklsd foo gfhdfhg

    assuming blue stuff is something like:

    Code:
    <font color='blue'>foo</font>
    or 
    <font color='blue' id = 'dsfasd' ...>foo</font>
    How to clear that (assuming I selected one of 'foo's), using execCommand or anything else to 'foo' only ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    So, in order to do something you must read selection underlying HTML.

    One cross browser method is here: http://www.codingforums.com/archive/.../t-154848.html, scroll to bottom.

    Now the problem that exist all the time, regardles of method used for reading
    underlying HTML .....

    consider this (note extra space in second line):

    Code:
    (<font color='blue'>foo</font>)
    ( <font color='blue'>foo</font> )
    In first case selecting 'foo' and using func for reading HTML, return would be 'foo', in second case selecting ' foo ' (with spaces) return would be ' <font color='blue'>foo</font> ' (with spaces).

    This(getting html) even work if you have 'foo,' and select all that, but gives you one extra unwanted ',' (in this case) inside HTML.

    Any solution to this ?

    All upper statements tested on FF.

    EDIT: the prob is in contentEditable = /true/false. In IE works OK regardlesa of state, in FF works same as IE OK if false, otherwise not.
    Last edited by BubikolRamios; 12-05-2012 at 04:04 PM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,639
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Just a reminder that the <font> tag was deleted from HTML back in 1997 and was one of those replaced by CSS.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Yes I know, but execCommand puts it in. Latest FF version (for fore color text).
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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