SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Function wont work in firefox

    This javascript function to copy text from a text field won't work in firefox 1.0

    Any ideas why?

    <script language="Javascript">
    <!--
    function copystring(str){
    holdtext.innerText = copytext.innerText.str;
    CopiedInfo = holdtext.createTextRange();
    CopiedInfo.execCommand("Copy");
    }
    //-->
    </script>

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what are holdtext & copytext? IDs? ...... A little more code would go a LONG way to helping you solve your issues!

  3. #3
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dc dalton
    what are holdtext & copytext? IDs? ...... A little more code would go a LONG way to helping you solve your issues!
    trying to get a quick function to copy text from an text field to the clip board

    Code:
      <script language="Javascript"> 
      <!-- 
      function  copystring(str){ 
      holdtext.innerText = str; 
      CopiedInfo =  holdtext.createTextRange(); 
      CopiedIfo.execCommand("Copy"); 
      }  
      //--> 
      </script>
    Code:
      call to it Use the following code to link  to this image from a forum or other location.<br><br> 
      With BB  code:<br> 
      <input type="text" name="bburl" size="56" value="[img]http://www.lionslair.net.au//user_imgs/48.jpg[/img]">  
      <a href="javascript:copystring('bburl')">copy  BBcode</a> 
      <br><br> 
      Without BB code:<br>  
      <input type="text" name="url" size="45" value="http://www.lionslair.net.au//user_imgs/48.jpg">  
      <a href="javascript:copystring('url')">copy  url</a>But I jsut can't get it to work in firefox.

  4. #4
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript newbie here. I found your question while researching why a script was working in IE and not Firefox. The answer I found may or may not help you. Go here:
    http://dotnetjunkies.com/WebLog/will.../25/48238.aspx

    What fixed my problem was finding that Mozilla variants to do not support "innerText". You have to use "innerHTML" instead.

  5. #5
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do believe TikTokk's on to something there. Neither innerText nor innerHTML are part of a recognized standard. Both started as IE-only properties. Most of the major browsers have adopted innerHTML as a convention, but its implementation is purely optional.

    Purists often imply that innerHTML is deprecated and that the W3C's conventions for object manipulation must therefore be adhered to. It is, however, unclear who has authority to declare the deprecation of a voluntarily adopted convention, one generally recognized to facilitate simple element manipulations. (Yes, you have to call the HTML-rendering engine in unseemly ways with innerHTML, but the occasional abuse of the HTML engine would hardly seem grounds to slur the poor beast with pronouncements of "deprecation".)


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
  •