Home > Backend Development > PHP Tutorial > 是不是隐形的加入了 rn

是不是隐形的加入了 rn

WBOY
Release: 2016-06-13 10:47:58
Original
802 people have browsed it

是否隐形的加入了 \r\n?
在记事本里 我们敲回车 文本会换行 是否隐形的加入了 \r\n?
我们如何去匹配呢?
就好像在编辑这个问题一样,敲一下就换行,是如何实现的?

------解决方案--------------------
js控制的,这样:
Demo:

HTML code
            <script language="javascript">            ns4 = (document.layers) ? true : false;            ie4 = (document.all) ? true : false;            function keyDown(e){                if(ns4){                    var nkey=e.which;                    var iekey='现在是ns浏览器';                    var realkey=String.fromCharCode(e.which);                }                if(ie4){                    var iekey=event.keyCode;                    var nkey='现在是ie浏览器';                    var realkey=String.fromCharCode(event.keyCode);                    if(event.keyCode==32){realkey='\' 空格\''}                    if(event.keyCode==13){realkey='\' 回车\''}                    if(event.keyCode==27){realkey='\' Esc\''}                    if(event.keyCode==16){realkey='\' Shift\''}                    if(event.keyCode==17){realkey='\' Ctrl\''}                    if(event.keyCode==18){realkey='\' Alt\''}                }                document.write('ns浏览器中键值:'+nkey+'\n'+'ie浏览器中键值:'+iekey+'\n'+'实际键为'+realkey);            }            document.onkeydown = keyDown;                if(ns4){                    document.captureEvents(Event.KEYDOWN);                }        </script>            //Javascript Document.    <hr>    <center>        <h3>请按任意一个键。。。。</h3>    </center><div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template