MacDevCenter    
 Published on MacDevCenter (http://www.macdevcenter.com/)
 See this if you're having trouble printing code examples


Mac Hacks

Kiosk Mode in Internet Explorer 5

04/27/2001

Also in Mac Hacks:

IE 5: Printing Framesets

Mac Hacks: Wild Hard Drive

Mac Hacks: The Launch

Internet Explorer 5 for Mac OS is designed as a general-purpose web browser, but some people like to use it for product demonstrations, trade show exhibits, or as an interactive Internet kiosk. The trouble with doing that is it leaves your Mac vulnerable to passersby trashing files, changing control panel settings, and otherwise wreaking havoc.

To prevent this, you need to set up IE 5 to open your kiosk page and disable all commands that allow changing the machine's Internet configuration. We will create a hacked version of the IE 5 application to achieve this goal.

Creating kiosk favorites

First, open the Explorer folder in the Preferences folder in your System folder. Select the Favorites.html file and choose "Duplicate" from the File menu. This file stores all your Internet Explorer Favorites.

Since you need to change your existing Favorites, you first should duplicate the old ones so that you can revert to them when you're not in kiosk mode.

The way I revert to my previous favorites is by opening this folder again, moving or renaming the current Favorites.html file, and removing the "copy" name from the old file.

Now launch Internet Explorer and set the preferences to the desired appearance you want for your kiosk. Typically you would make your intro page the home page and check the "Automatically go to this home page when opening a new window" preference.

Then navigate to each of the pages you want to be available from this new Favorites menu and choose "Add Page to Favorites". When you've done this, choose "Organize Favorites" and set up your Favorites menu and tool bar by adding folders and dividers, and deleting any favorites you don't want made available.

If you will be using local files exclusively and not loading pages from the Internet, select the "Work Offline" command from the File menu. If you want to prevent users from viewing past pages, set the history in the Advanced preferences panel to zero pages. If you want to prevent users from accessing other internet applications, uncheck the appropriate helpers in the Protocol Helpers preference. Quit IE when you're done.

Hacking the application

Next, open the Internet Explorer 5 folder in your Internet or Microsoft Internet 5 folder, and duplicate the Internet Explorer 5 application. You should always make a duplicate of any file you are going to hack; this leaves a version of the application that works normally and allows you to revert to the original version if you make a mistake. Once you have made the duplicate application, change its name to "IE Kiosk" in Finder.

Now we will change the menu commands in the IE Kiosk application. To do this, we need a resource editing application like ResEdit or Resourcerer. ResEdit is available at many software archives, including versiontracker.com, and is invaluable for any serious Mac OS hacking. The following descriptions assume you are using ResEdit, but the same features are available from other resource editors.

Drag the IE Kiosk application to the ResEdit icon, or launch ResEdit and open IE Kiosk from the File menu. Choose "Get Info for IE Kiosk" from the File menu, and uncheck the "Has BNDL" checkbox in the Info window. If you don't do this, double-clicking an HTML file will open it in your kiosk application instead of IE.

Once you've done that, double-click the MENU resource in the IE Kiosk window. This will open a "MENUs" window which shows all the menus in the application. Double click the File menu, probably ID 257. In this menu editor, scroll to the bottom of the menu commands displayed and click the Quit item. Note that this will not quit anything, it just selects that command from the list of commands in the File menu. Click the Delete key or choose "Clear Item" from the Edit menu to remove the Quit command. Do the same to the "Work Offline" command and the two dotted separator lines now at the end.

Screen shot -- click for full-size view.
Accessing the Menu file in ResEdit -- click for full-size view.

If you want to remove the user's ability to print or to transfer favorites, delete the Print and Favorites commands from the File menu as well. What you will not be able to do is delete the Favorites commands without deleting the Print commands. Mac IE uses the position of commands in menus, so you cannot delete a command from the middle of a menu; you have to delete commands from the end of the menu.

In the same manner, remove the Preferences command and separator line from the Edit menu, probably menu ID 258. You may also want to delete some commands from the View menu. Remember, you can only delete commands from the end of the list, and you cannot delete the menu resource itself. When you're done, choose "Save" and quit ResEdit.

If you make a mistake, choose the "Revert File" command from ResEdit's File menu to revert to the last saved version of the file. If you saved the file with a mistake, you will have to close the file, trash it, and make a new copy in Finder.

Now try running the IE Kiosk application. You should be able to navigate between pages but should not be able to quit it or change preferences. If it crashes, throw out your IE Kiosk application and ResEdit another duplicate, and don't delete so many commands this time.

And a dash of AppleScript ...

If it doesn't crash, you will need to know how to quit it without a Quit command. The easiest way is to force-quit it by pressing Command-option-esc, but a more elegant method is to use AppleScript. Open the Apple Script Editor application and run the following command:

tell application "IE Kiosk" to quit

Stay out of my Finder!

Now you have a kiosk application that users can't easily quit, and they can't change the preferences. If you want to prevent users changing system preferences or running other applications, you have to prevent them from running Finder.

To do this, first create an alias to the IE Kiosk application and drag it to the Startup Items folder in your system folder. Then run the Script Editor program again and save a compiled script file with the command:

tell application "Finder" to quit

into the Startup Items folder.

Now, when you restart, Finder will quit, your kiosk application will start, and users will not be able to run any Mac OS applications or change your machine configuration. The only way to get out of this is to hit Command-option-esc or the reset button on your Mac and hold the Shift key down so it starts without running Startup Items. If you take the interrupt button and keyboard away from the kiosk even people who know how this works won't be able to escape it.

The same principle can be used to make kiosk modes out of many applications. Note that not all applications will run after their resources have been edited in this way.

Richard Hough is a web developer for a Vancouver, Canada educational software company.


Read more Mac Hacks columns.

Return to the Mac DevCenter.

Copyright © 2009 O'Reilly Media, Inc.