5 Replies Latest reply on Mar 6, 2012 12:55 PM by dloughlin

    newlines in Chrome vs IE8

    dloughlin

      Using IE8 when I enter text (with newlines using the enter key) into a textarea and using the onchange event and ajax, I submit the new text into a FMServer 11.5 database, all works well. I can view that field with FMPro, and the newlines(or carriage returns or whatever you want to call them) are preserved.

      When I do the same with Chrome (and I think also IE9), the carriage returns have been dropped when the field is viewed with FMPro. Interestingly, when I view the text( with an alert dialog) that was sent with the ajax call, it has the carriage returns, and also when I echo the text that was used by the php script that used the Filemaker API (using setField), back to the javascript (the ajax response) and view that with an alert, the carriage returns are still intact.

      So it appears, that the newline that is passed by Chrome to the Filemaker API, is being ignored.

      an example would be, when I enter the following in the textarea element:

       

      aaa

      bbb

      ccc

       

      when viewed in the DB with FMPro it looks like what is input, but when the same is done with Chrome, it looks like the following:

       

      aaabbbccc

       

      If anyone can shed any light on this, it would be greatly appreciated.

       

      Dennis Loughlin

        • 1. Re: newlines in Chrome vs IE8
          Stephen Huston

          Hi Dennis,

           

          I've no experience with this specific problem, but several things might be affecting this based on how the fields are set on the FM layout, how the various browsers interpret those settings, and the specific keys used to enter the line/returns.

           

          1. Are the fields in question set to Go to Next Field when Enter or Returns are keyed. This is controlled in the Inspecotr panel, and will affect whether or not line/returns can be entered in Pro. How a browser interprets that code can vary.
          2. Is there any difference if the line/return is entered via the Enter-key vs the Return-key? FileMaker interprets these keys differently though most users think they are interchangeable. A browser might also treat them differently.

           

          That's all the ideas I have based on the details so far. Try testing changes to these options and report what happens.

           

          Stpehen Huston

          • 2. Re: newlines in Chrome vs IE8
            dloughlin

            Thanks for the response, after more searching on the web, I cam across the following solution, which I incorporated in my php script, and it appears to have corrected the problem. Haven't tested on IE9 yet, but works with Chrome.

             

            str_replace(array("\n","\n\r","\r"),"\r",$myfield);

             

            If I find I still have some issues with other Browsers, I'' post it here

            • 3. Re: newlines in Chrome vs IE8
              dloughlin

              Oops, spoke too quick, turns out that with the change, in IE8 I get a blank line between lines. In other words a double line feed.

              • 4. Re: newlines in Chrome vs IE8
                Stephen Huston

                Can you write your PHP code  to behave differently in  different browsers/versions?

                 

                A lot of bother, but whatever works is usually worth it.

                • 5. Re: newlines in Chrome vs IE8
                  dloughlin

                  apparently IE8 puts a CR/LF in wile Chrome and IE9 justs put a LF in when the Enter key is used. It also seems that Filemaker only recognizes the CR.

                   

                  So what I did was replace all occurences of  CR/LF with LF, and then replace all occurrences of LF with CR.

                  This apparently works in all three browswer (IE8,IE9, and Chrome). Haven't tested in other browsers yet, but hopefully..................

                   

                  Thanks for the rseponses