Brian Cryer

 

Cry How To...


Create a CD that will autorun an HTML file maximized


For notes on how to create a CD that will autorun please refer to the article ‘Create a cd that will autorun’.

To create a cd that will autorun to open the html file ‘index.htm’ non-maximized would require the following ‘autorun.inf’ file:

[autorun]
ShellExecute=index.htm

There are two methods to create a CD that will autorun, displaying an HTML file maximized:


Method 1: Use Windows Shell

The following ‘autorun.inf’ file invokes the command processor to start a full screen browser on the html file ‘index.htm’:

[autorun]
open=command /c start /max index.htm

Be aware that the use of ‘command’ and ‘start’ restrict this to machines running Windows. It is therefore not portable to other platforms.


Method 2: Use JavaScript

An alternative approach is to use JavaScript to maximize the HTML file after it has been displayed. The ‘autorun.inf’ file requires nothing other than to invoke the browser:

[autorun]
ShellExecute=index.htm

In order to be maximized the HTML file would require the following JavaScript to be included. The obvious place for it would be just inside the opening '<BODY> tag or just before the closing '</HEAD>' tag.

<script type="text/javascript">
<!--
if (document.all || document.layers)
{
  window.moveTo(0,0);
  window.resizeTo(screen.availWidth,screen.availHeight)
} else if (window.screen) {
  window.moveTo(0,0);
  window.outerHeight = screen.availHeight;
  window.outerWidth = screen.availWidth;
}
//-->
</script>

The disadvantage of this approach is that it isn't strictly maximizing the window - it is resizing it to take advantage of the full screen size, but it should be portable to non-Windows platforms.


These notes are believed to apply to all versions of Windows.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.