kiosk_mode.md 1.69 KB
Newer Older
1
# Kiosk Mode
2

3 4
If you have a real world kiosk application that you want to run on Google
Chrome, then below are the steps to take to simulate kiosk mode.
5 6 7 8 9 10 11

## Steps to Simulate Kiosk Mode

### Step 1

Compile the following Java code:

12
```java
13 14 15 16 17 18 19 20 21 22 23
import java.awt.*;
import java.applet.*;
import java.security.*;
import java.awt.event.*;

public class FullScreen extends Applet
{
   public void fullScreen()
   {
      AccessController.doPrivileged
      (
24
         new PrivilegedAction()
25
         {
26
            public Object run()
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
            {
               try
               {
                  Robot robot = new Robot();
                  robot.keyPress(KeyEvent.VK_F11);
               }
               catch (AWTException e)
               {
                  e.printStackTrace();
               }
               return null;
            }
         }
      );
   }
}
```

### Step 2

Include it in an applet on your kiosk application's home page:

49 50 51 52 53
```html
<applet name="appletFullScreen"
        code="FullScreen.class"
        width="1"
        height="1"></applet>
54 55 56 57 58 59 60 61
```

### Step 3

Add the following to the kiosk computer's java.policy file:

```
grant codeBase "http://yourservername/*"
62
{
63 64 65 66 67 68
   permission java.security.AllPermission;
};
```

### Step 4

69 70
Include the following JavaScript and assign the `doLoad` function to the
`onload` event:
71

72
```javascript
73 74 75 76 77 78 79 80 81 82 83 84
var _appletFullScreen;

function doLoad()
{
   _appletFullScreen = document.applets[0];
   doFullScreen();
}

function doFullScreen()
{
   if (_appletFullScreen && _appletFullScreen.fullScreen)
   {
85 86
      // Add an if statement to check whether document.body.clientHeight is not
      // indicative of full screen mode
87 88 89
      _appletFullScreen.fullScreen();
   }
}
90
```