Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

You may receive an "Access is denied" error message when you try to access a Web page that contains a script in Internet Explorer 6


View products that this article applies to.

Symptoms

Consider the following scenario:
  • You have a computer that is running Microsoft Windows XP with Service Pack 2 (SP2) or Windows Server 2003 with SP1.
  • You try to access a Web page in Microsoft Internet Explorer 6.
  • The Web page contains a script.
In this scenario, you may receive the following error message:
Line: Line_Number
Char: Character Number
Error: Access is denied
Code: 0
URL: file:/// URLPath/Filename
The following line in the script code raises the error message.
event.KeyCode = 0;

↑ Back to the top


Cause

This problem occurs when you try to access a Web page from the local file system, and the local file system contains the event.KeyCode property in the script. This is a security change in Internet Explorer 6 on Windows XP with SP2 and on Windows Server 2003 with SP1. You can no longer access the event.keyCode property by using the SHIFT key or the CTRL key on Web pages that are loaded from the local disk.

↑ Back to the top


Resolution

To resolve this problem, change the code that assigns the event.keyCode property so that it does not change the value. The change in the code lets you use the SHIFT key or the CTRL key to load pages from the local disk

Alternatively, you can host the Web pages on a Web server. This makes sure that the event.keyCode property in the script runs correctly.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

Steps to reproduce the problem

  1. Install Windows XP with SP2 or Windows Server 2003 with SP1.
  2. Paste the following code in a text file, and then save the file as TestKeyCode.htm on the local hard disk.
    <HTML>
    <HEAD>
    <SCRIPT>
    function onJScriptKeyDown()
    {
      event.keyCode = 0;
    }
    </SCRIPT>
    <HEAD>
    
    <BODY>
    Test
    <INPUT onkeydown="onJScriptKeyDown();"
    </INPUT>
    </BODY>
    
    </HTML>
    
  3. Open the TestKeyCode.htm file in Internet Explorer 6 by using the file protocol.

    For example, type the following address in the Address bar:
    file:/// C :/TestKeyCode.htm
  4. Click the Test box to set the focus.
  5. Press SHIFT or press CTRL.

↑ Back to the top


References

For more information about the keyCode property, visit the following Microsoft Developer Network (MSDN) Web site:

↑ Back to the top


Keywords: KB934364, kbprb, kbscript, kbfix, kbtshoot, kberrmsg

↑ Back to the top

Article Info
Article ID : 934364
Revision : 3
Created on : 11/22/2007
Published on : 11/22/2007
Exists online : False
Views : 303