andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 1 | # Kiosk Mode |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 2 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 3 | If you have a real world kiosk application that you want to run on Google |
| 4 | Chrome, then below are the steps to take to simulate kiosk mode. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 5 | |
| 6 | ## Steps to Simulate Kiosk Mode |
| 7 | |
| 8 | ### Step 1 |
| 9 | |
| 10 | Compile the following Java code: |
| 11 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 12 | ```java |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 13 | import java.awt.*; |
| 14 | import java.applet.*; |
| 15 | import java.security.*; |
| 16 | import java.awt.event.*; |
| 17 | |
| 18 | public class FullScreen extends Applet |
| 19 | { |
| 20 | public void fullScreen() |
| 21 | { |
| 22 | AccessController.doPrivileged |
| 23 | ( |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 24 | new PrivilegedAction() |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 25 | { |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 26 | public Object run() |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 27 | { |
| 28 | try |
| 29 | { |
| 30 | Robot robot = new Robot(); |
| 31 | robot.keyPress(KeyEvent.VK_F11); |
| 32 | } |
| 33 | catch (AWTException e) |
| 34 | { |
| 35 | e.printStackTrace(); |
| 36 | } |
| 37 | return null; |
| 38 | } |
| 39 | } |
| 40 | ); |
| 41 | } |
| 42 | } |
| 43 | ``` |
| 44 | |
| 45 | ### Step 2 |
| 46 | |
| 47 | Include it in an applet on your kiosk application's home page: |
| 48 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 49 | ```html |
| 50 | <applet name="appletFullScreen" |
| 51 | code="FullScreen.class" |
| 52 | width="1" |
| 53 | height="1"></applet> |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 54 | ``` |
| 55 | |
| 56 | ### Step 3 |
| 57 | |
| 58 | Add the following to the kiosk computer's java.policy file: |
| 59 | |
| 60 | ``` |
| 61 | grant codeBase "http://yourservername/*" |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 62 | { |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 63 | permission java.security.AllPermission; |
| 64 | }; |
| 65 | ``` |
| 66 | |
| 67 | ### Step 4 |
| 68 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 69 | Include the following JavaScript and assign the `doLoad` function to the |
| 70 | `onload` event: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 71 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 72 | ```javascript |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 73 | var _appletFullScreen; |
| 74 | |
| 75 | function doLoad() |
| 76 | { |
| 77 | _appletFullScreen = document.applets[0]; |
| 78 | doFullScreen(); |
| 79 | } |
| 80 | |
| 81 | function doFullScreen() |
| 82 | { |
| 83 | if (_appletFullScreen && _appletFullScreen.fullScreen) |
| 84 | { |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 85 | // Add an if statement to check whether document.body.clientHeight is not |
| 86 | // indicative of full screen mode |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 87 | _appletFullScreen.fullScreen(); |
| 88 | } |
| 89 | } |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 90 | ``` |