Microsoft KB Archive/816885

= &quot;Permission denied&quot; error message when you read properties of the Location object that is inside an HTML Application =

Article ID: 816885

Article Last Modified on 5/21/2007

-

APPLIES TO


 * Microsoft Internet Explorer 6.0 Service Pack 1

-



SYMPTOMS
When you read certain properties of the Location object that is inside an HTML Application (HTA), you may receive a &quot;Permission denied&quot; error message. The relevant properties of the Location object include:
 * Location.href
 * Location.hostname
 * Location.reload

Note You may notice this error only if you use an automatic configuration script in the Local Area Network (LAN) settings of Microsoft Internet Explorer.

If debugging tools are installed on your computer, you may receive an error message that is similar to the following:

A Runtime Error has occurred. Do you wish to Debug? Line 12 Error: Permission denied

If debugging tools are not installed on your computer, you may receive an error message that is similar to the following:

An error has occurred in the script on this page. Line: 13 Char: 2 Error: Permission denied Code: 0 URL: http://WebServer/ .hta Do you want to continue running scripts on this page?

Note You may notice this problem only if your automatic configuration script has the DIRECT value.



RESOLUTION
To resolve this problem, use any of the following methods:

Note The following methods are based on the sample that is mentioned in the &quot;More Information&quot; section of this article. Therefore, the code and the file names in these methods may differ from your code and from your file names.
 * Hard code a proxy server in the Proxy server settings of Internet Explorer instead of using an automatic configuration script, and then press F5 to refresh the HTA in the browser.
 * Use a host name instead of a Fully Qualified Domain Name (FQDN) to access the path to the HTA.
 * Use an IP address to access the HTA.
 * Add the Web site that you are accessing to the Trusted zone or to the Restricted zone.
 * Do not use the Location object in your code.
 * Click to clear the Include all sites that bypass the proxy server check box in the Security settings of Internet Explorer.



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Start Internet Explorer. On the Tools menu, click Internet Options. On the Connections tab, click LAN Settings. In the Local Area Network (LAN) settings dialog box, click to select the Use automatic configuration script check box. Make sure that none of the other check boxes is selected. In the Address box, type the path to the automatic configuration script. Use Notepad to create a text file that is named Default.hta.</li>  Add the following HTML code to the Default.hta file: HTA Location.href bug reproduction

<HTA:APPLICATION ID=&quot;oBugRepro&quot; APPLICATIONNAME=&quot;BugRepro&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;> function ShowFrame { var strLocation; strLocation = top.fraTabs.location.href; } </SCRIPT>

<frameset id=&quot;fstWorkAreaMain&quot; name=&quot;fstWorkAreaMain&quot; rows=&quot;40%,60%&quot;>

<frame src=&quot;about:blank&quot; id=&quot;fraTabs&quot; name=&quot;fraTabs&quot; APPLICATION=&quot;yes&quot;> <frame src=&quot;Main.htm&quot; id=&quot;fraMain&quot; NAME=&quot;fraMain&quot; APPLICATION=&quot;yes&quot;>

</li> Use Notepad to create a text file that is named Main.htm.</li>  Add the following HTML code to the Main.htm file: <HTML> <BODY style=&quot;background-color:gainsboro&quot;>

<P>Main frame</P>

<input id=&quot;cmdButton&quot; type=&quot;button&quot; onclick=&quot;top.ShowFrame&quot; value=&quot;Click me to reproduce the behavior&quot;>

</BODY> </HTML> </li> Place the two files, Default.hta and Main.htm, in a virtual directory that is named HTARepro on a Web server.</li> Make sure that you have enabled anonymous access to the contents of the HTARepro virtual directory.</li> Type the following command at a command prompt:

mshta.exe http:// /HTARepro/Default.hta

Note Replace  with the FQDN of the Web server that you are using.</li> On the HTA application, click Click me to reproduce the behavior. You receive one of the error messages that are mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">