Textarea HTML editor compatible with Opera

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles

    #1

    Textarea HTML editor compatible with Opera

    Hi folks,

    I am desperatly looking for a WYSIWYG HTML editor for a textarea, using JavaScript and that'll work
    with Opera.
    I want this editor to use for a webmail program in PHP, and allow users to send HTML email.
    All HTML editors I found out on the web work for most browsers except Opera.
    Does any of you guys know of an Opera-friendly editor?
    That would be great...
    Thanks,

    --
    Charles.


  • Yann-Erwan Perio

    #2
    Re: Textarea HTML editor compatible with Opera

    Charles wrote:
    [color=blue]
    > I am desperatly looking for a WYSIWYG HTML editor for a textarea, using JavaScript and that'll work
    > with Opera.[/color]

    Generally, two techniques can be used to design such editors:
    - "design mode" model,
    - selection/transformation model, using text ranges.

    AFAIK, only IE supports these two methods (although Mozilla may have
    included some, I'm late in my browser testing), so unfortunately I don't
    think you'll find the kind of editor you're looking for working on Opera.
    [color=blue]
    > I want this editor to use for a webmail program in PHP, and allow users to send HTML email.[/color]

    Well, you could let them write custom-HTML and offer them a preview area
    (Opera 7+ does support innerHTML and DOM methods) eg something like
    (slightly tested only, but you see the point):


    <form action="foo" onsubmit="retur n false">
    <textarea name="editArea" ></textarea>
    <input type="button"
    onclick="p(this .form.elements['editArea'].value);"
    value="Preview" >
    </form>

    <div id="previewArea "></div>

    <script type="text/javascript">
    function p(s){
    // we only accept B, I, A tags
    // a tag is defined as [T]content[/T]
    // or [A href="foo"]content[/A]
    var re = /\[([abi])(\s+href="[^"]+")?\](.*?)\[\/\1\]/ig;
    s=s.replace(/</g,"&lt;").repla ce(/>/g,"&gt;");
    s=s.replace(re, function(a, b, c, d) {
    c = c || "";
    if (d) d = d.replace(re, arguments.calle e);
    return "<" + b + c + ">" + d +"<\/" + b + ">";
    });
    document.getEle mentById("previ ewArea").innerH TML=s;
    }
    </script>


    Good luck,
    Yep.

    Comment

    • Charles

      #3
      Re: Textarea HTML editor compatible with Opera

      Thanks ;-)

      --
      Charles.


      Comment

      Working...