javascript problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cyuno
    New Member
    • Aug 2010
    • 4

    javascript problem

    The following code works in a textarea box Firefox but not IE8:

    Code:
    <script language="javascript">
    function repp()
    {
    var ss = document.getElementById('text').value;
    ss = ss.replace(/(\r\n)|(\n)/g,"<br />");
    document.getElementById('text').value = ss;
    }
    </script>
    In IE, when you hit enter, there are no carriage returns and the text line does not break.

    Thanks in advance for your help
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    You might have to use Alt-Enter to make microsloth's software do your bidding.

    Also, the pattern might want to be:
    Code:
    ss = ss.replace(/(\r\n)|(\n)|(\r)/g, "<br />");
    Cheers!

    Cheers!

    Comment

    • cyuno
      New Member
      • Aug 2010
      • 4

      #3
      javascript problem

      I made the change but IE still refuses to recognize hitting enter for carriage return in the textarea. Also hitting alt enter gives me a full screen view without the browser (I'm on windows xp)

      Thanks for the quick response!

      Regards,
      cyuno

      Comment

      • Oralloy
        Recognized Expert Contributor
        • Jun 2010
        • 988

        #4
        @cyuno,

        There may be some options you can set on the textarea that allow it to capture carriage returns (CR) transparently.

        I'm not sure why you're having problems. I use XP and I.E. 8 with few problems. I do know, from programming windows with C++, that text boxes can be set up to be CR sensitive or not. Perhaps that's your issue?

        Comment

        • cyuno
          New Member
          • Aug 2010
          • 4

          #5
          Yes. I have a div which is separate from the textarea box which reflects what is being typed in the textarea box. In Firefox, the div exactly captures what is in the textarea box including CRs. This is not the case with IE.

          Comment

          Working...