19
|
1 <!doctype html>
|
|
2 <html>
|
|
3 <head>
|
|
4 <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5 <style>
|
|
6 [contentEditable] {
|
|
7 padding: 7px;
|
|
8 border: 1px solid #777;
|
|
9 white-space: pre-wrap;
|
|
10 }
|
|
11 </style>
|
20
|
12 <script src="/site.js"></script>
|
19
|
13 <script>
|
20
|
14 function getBrowser() {
|
|
15 let userAgent = navigator.userAgent;
|
|
16 if( userAgent.match(/chrome|chromium|crios/i) )
|
|
17 return 'chrome';
|
|
18 if( userAgent.match(/firefox|fxios/i) )
|
|
19 return 'firefox';
|
|
20 if( userAgent.match(/safari/i) )
|
|
21 return 'safari';
|
|
22 if( userAgent.match(/opr\//i) )
|
|
23 return 'opera';
|
|
24 if( userAgent.match(/edg/i) )
|
|
25 return 'edge';
|
|
26 return "unknown";
|
|
27 }
|
|
28
|
19
|
29 function log() {
|
|
30 let edit = document.querySelector('[contentEditable]');
|
|
31 console.log(edit.innerHTML);
|
|
32 //console.log(edit.textContent);
|
|
33 }
|
|
34 function test() {
|
|
35 let edit = document.querySelector('[contentEditable]');
|
|
36 edit.focus();
|
20
|
37 editorEnter();
|
19
|
38 }
|
|
39 </script>
|
|
40 </head>
|
|
41 <body>
|
|
42 <p>top</p>
|
20
|
43 <div contentEditable onkeypress="return editorKey()">
|
19
|
44 aaa <b>bbb</b> <i>iii</i>
|
|
45 1
|
|
46 2
|
|
47 3
|
|
48 zzz
|
20
|
49 </div>
|
19
|
50 <p>
|
|
51 <button onclick="log()">log</button>
|
|
52 <button onclick="test()">test</button>
|
|
53 </p>
|
|
54 <p>bottom</p>
|
|
55 </body>
|
|
56 </html>
|