Results 1 to 3 of 3

Thread: HTML tags not working in Firefox

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,297
    Thanks
    98
    Thanked 104 Times in 102 Posts

    Default HTML tags not working in Firefox

    Hi,

    I am not fluent in javascript at all, but I have this relatively simple program that works in Opera and IE, but not Firefox. Anyone have an idea on how the script can be altered to work in Firefox?

    Code:
    <script type="text/javascript"> 
    function insertAtCursor(myField, myValue) {
      //IE support
      if (document.selection) {
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
      }
    else 
    {
        myField.value += myValue;
      }</script>
    <script type="text/javascript"> 
    function saveCurRng() { 
    curRng = document.selection.createRange().duplicate(); 
    } 
    function surround(btag, etag){ 
    if (curRng) { 
    document.editform.article.focus(); 
    curRng.text= btag + curRng.text + etag; 
    return false; 
    } 
    } 
    </script> 
    </head> 
    <body> 
    <form name="editform"> 
    <textarea rows=5 cols=40 name="article" onKeyup="saveCurRng()" onMouseup="saveCurRng()"></textarea> 
    </form> 
    <a href="#" onclick="return surround('<b>', '</b>');">bold</a><br> 
    <a href="#" onclick="return surround('<i>', '</i>');">italic</a>
    Last edited by james438; 11-18-2009 at 12:08 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,297
    Thanks
    98
    Thanked 104 Times in 102 Posts

    Default

    Sorry, I updated the script to remove the junk code.
    To choose the lesser of two evils is still to choose evil. My personal site

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,297
    Thanks
    98
    Thanked 104 Times in 102 Posts

    Default

    The solution can be found in this thread.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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