Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Internet Explorer 5+ Extensions

0.00/5 (No votes)
13 May 2005 1  
A variety of new and used Internet explorer extensions available from a 'right click'
Sample Image - ieextensions_menu.gif Sample Image - document_scripts.gif

Introduction

I first came across useful extensions for Internet Explorer when Microsoft packaged IE4 Power Toys. Things seemed to then go quiet for IE5, so I took the ideas, and with a little help from an MSDN article, I created a few more useful bits and pieces for IE.

Included Extensions

  1. Show / Hide table borders (for page) - useful for web development / layout.
  2. View Selected Source (for selected text) *
  3. View Stylesheets (for page).
  4. View Scripts (for page).
  5. Highlight (for selected text) *
  6. De-highlight (for selected text) *
  7. Zoom In (for selected image) *
  8. Zoom Out (for selected image) *

* From IE4 Power Toys.

How does it work?

The whole thing works entirely in HTML/JavaScript, and the knowledge that IE can grab a read-only copy of the document currently loaded in the browser. This means that these extensions are extremely useful for labour saving on working out the makeup of a page.

What can you do?

The most useful thing is that you have access to the document object through the following JavaScript code.

var win = external.menuArguments;
var doc = win.document;   //Owning document

These lines then allow you to address doc as a normal document object.

The 'Show / Hide Table Borders' page is implemented as simply as the following JavaScript:

<SCRIPT>
    var win = external.menuArguments;
    var doc = win.document;
    for (i=0;i<doc.all.tags("TABLE").length;i++) 
    {
        if (doc.all.tags("TABLE")[i].border == 0)
            doc.all.tags("TABLE")[i].border = 1;
       else
            doc.all.tags("TABLE")[i].border = 0;
    }
</SCRIPT>

Points of Interest

New Windows

Some of the pages create new windows. The important thing to remember is that you can only operate 'read-only' on the currently loaded browser document. This means that if you want to show some information about the page you'll most likely need to create a new window. The following pages (in the installation) give examples of this:

  • showstylesheets.htm
  • viewselectedsource.htm
  • showscripts.htm

Issues

I found that there are a number of pitfalls...

  1. Frames tend to be problematic, as the sandbox the script runs in may not have access to look at other frames.
  2. If you're intending to pop up a window to display some information, then make sure you don't have any popup blocker running (else you'll get a permission denied error).
  3. You may also find that some properties that you can see in a debugger can't be accessed through this code. I found this was the case in IE6 with properties like document.location (you can use URL instead, however).

Hooking it all up

The HTML files can go anywhere, but normally go into %systemroot%\web (e.g. c:\windows\web or c:\winnt\web), and the context menu comes from registry entries found at HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt.

Each item can apply to different contexts (see the MSDN article for details on implementing that).

Installation

I chose to use Visual Studio .NET to create a Windows Installer package (I previously used a .inf file). This will copy the HTML files to c:\IEExtensions and create appropriate registry entries. I chose this folder location as I didn't get round to putting conditions in the installer based on the operating system!

Make sure you close down all instances of IE as the extensions won't show up until IE loads from scratch again.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here