SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Introduction : The "external.menuArguments"

The other half of a context menu addition is the script. Internet Explorer will read this script, place it in a hidden window, then run it. From the ".REG" file half, we already know that this file is called "640window.html", it is located in "C:\WINDOWS\WEB\", and it is shown only in the default context menu. Here is the complete file:

<SCRIPT LANGUAGE="JavaScript" DEFER>
        external.menuArguments.top.resizeTo(640,480);
</SCRIPT>

Notice there are no <HTML>, <HEAD>, or <BODY> tags, despite the script's ".HTML" extension. These are only useful if you are writing a pop-up dialog box. Other than that, though, this file is almost like a normal HTML document. It even has it's own "window" object (though IE5 blocks access to some methods, including "alert()".

                                                    
<SCRIPT LANGUAGE="JavaScript" DEFER>

The "DEFER" attribute is probably new to you. It is a part of the HTML 4.0 standard, and tells a browser that this script can be ignored until the rest of the page is loaded. Earlier references from Microsoft were unclear on what type of speed-up this tag provided, so some people (like me) just added it blindly. It also caused Internet Explorer 4 to generate errors if the code contains user-made functions.

  external.menuArguments.top.resizeTo(640,480);

The context menu script is given access to the current window via "external.menuArguments", which is the current window's "window" object. If the document is within a frame, then "external.menuArguments" is the current frame's "window".

"resizeTo(X,Y)" is a method (a.k.a. function or subroutine) of the "window" object. In Internet Explorer, it resizes a browser window's outer dimentions to X by Y pixels. The "top" property inbetween "resizeTo(640,480)" and "external.menuArguments" holds the "window" object that is the highest in the frame hierarchy. This makes sure that the main browser window is resized, whether or not the current "window" is part of a frameset (try removing the "top." part and using the script on a frameset).

To summarize, that one line of script tells Internet Explorer to resize the main browser window to 640x480 pixels. When this file is saved as "640window.html", moved to "C:\WINDOWS\WEB\", and the registry information is added via the registry file, then the script can be called by right-clicking on a blank spot on an internet page and choosing "Resize to 640x480".

Have you got it? Good, because here comes another sample.

Page 1:Introduction
Page 2:The Registry Information
Page 3:The Contexts Available
Page 4:The "external.menuArguments"
Page 5:The Second Example
Page 6:The Image Hiding
Page 7:The Image Showing