1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <title>queryCommandEnabled bug</title> |
---|
5 | <script type="text/javascript"> |
---|
6 | |
---|
7 | window.onload = function() |
---|
8 | { |
---|
9 | // Catch the keydown event (not related to the bug). |
---|
10 | if ( window.document.addEventListener ) |
---|
11 | window.document.addEventListener( 'keydown', Document_OnKeyDown, false ) ; |
---|
12 | else |
---|
13 | window.document.attachEvent( 'onkeydown', Document_OnKeyDown ) ; |
---|
14 | |
---|
15 | // Enable editing when the page. |
---|
16 | if ( (/msie/).test( navigator.userAgent.toLowerCase() ) ) |
---|
17 | document.body.contentEditable = true ; |
---|
18 | else |
---|
19 | document.designMode = 'on' ; |
---|
20 | } |
---|
21 | |
---|
22 | function Document_OnKeyDown( ev ) |
---|
23 | { |
---|
24 | var keyCode = ev.keyCode || ev.which ; |
---|
25 | |
---|
26 | if ( keyCode == 16 || keyCode == 32 ) // Safari doesn't catch "Shift". |
---|
27 | { |
---|
28 | alert( document.queryCommandEnabled( 'Bold' ) ) ; |
---|
29 | alert( document.queryCommandState( 'Bold' ) ) ; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | </script> |
---|
34 | </head> |
---|
35 | <body> |
---|
36 | <p> |
---|
37 | <b>Select a word in this phrase and press the [Shift]* key. You should see two alerts, |
---|
38 | the first must say "true" and the second must say "true".<br /><span style="color: Red">Opera |
---|
39 | will fail in this case.</span></b> |
---|
40 | </p> |
---|
41 | <p> |
---|
42 | Select a word in this phrase and press the [Shift]* key. You should see two alerts, |
---|
43 | the first must say "true" and the second must say "false". |
---|
44 | </p> |
---|
45 | <p> |
---|
46 | * On Safari, hit the [Space] key instead.</p> |
---|
47 | </body> |
---|
48 | </html> |
---|