1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title></title> |
---|
5 | <meta charset="utf-8"> |
---|
6 | </head> |
---|
7 | <body> |
---|
8 | |
---|
9 | <p>Click on editable body, link and outside body - on html element. Compare between browsers which events are fired.</p> |
---|
10 | |
---|
11 | <iframe id="editable"></iframe> |
---|
12 | |
---|
13 | <script> |
---|
14 | |
---|
15 | var iframe = document.getElementById( 'editable' ); |
---|
16 | |
---|
17 | iframe.contentWindow.document.write( |
---|
18 | '<html>' + |
---|
19 | '<head>' + |
---|
20 | '<title></title>' + |
---|
21 | '<style>body { background: #AAA } html { background: #555 }</style>' + |
---|
22 | '</head>' + |
---|
23 | '<body contenteditable="true">' + |
---|
24 | '<p>text <a href="#">link</a> text.</p>' + |
---|
25 | '</body></html>' ); |
---|
26 | |
---|
27 | setTimeout( function() { |
---|
28 | var body = iframe.contentWindow.document.body; |
---|
29 | |
---|
30 | body.addEventListener( 'focus', function() { |
---|
31 | console.log( 'focus' ); |
---|
32 | } ); |
---|
33 | body.addEventListener( 'blur', function() { |
---|
34 | console.log( 'blur' ); |
---|
35 | } ); |
---|
36 | }, 100 ); |
---|
37 | |
---|
38 | </script> |
---|
39 | |
---|
40 | </body> |
---|
41 | </html> |
---|