IE8 Refuses to run Javascript from Local Hard Drive

23,732

Solution 1

Open registry key

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\n

Where n is the zone index, where 0 means My Computer. This zone is not available in Internet Options. Set Value 1400 to 0 to enable Javascript.

Solution 2

Have you tried to add a "Mark of the Web" in your HTML source?

Just add something like:

<!DOCTYPE html>
<!-- saved from url=(0021)http://www.google.com -->
<html>

A Mark of the Web is after the DOCTYPE tag, alone on a separate line, just before <html>.

See the MSDN documentation on Mark of the Web for full help.

Solution 3

if the computer is subject to corporate security policies, you may consider setting up a virtual machine (e.g. with Virtual Box or MS Virtual PC) to test your java scripts.

Microsoft offers a variety of pre-activated virtual hard drives (they work with VirtualBox and VPC) with either Vista or XP and IE6, 7 and 8. Internet Explorer Application Compatibility VPC Images are free and the current set is valid until April 1, 2010.

Solution 4

I know other persons who had this issue, so I investigated into it.

After lot of efford to replicate the error, I found the culprit.

read this: http://social.answers.microsoft.com/Forums/en-US/InternetExplorer/thread/2a0b55bf-6807-4f72-b10c-53f958af9b42 and http://social.technet.microsoft.com/Forums/en-US/w7itprosecurity/thread/90c3202c-448b-42b7-acf7-dab8dba7b000

Seems that something (a virus, or some software update) mess with the internet zones.

To fix the problem I exported all the registry and with a editor(ultraedit) searched for "\Internet Settings\Zones\" founding a key like "{Exadecimal-USER-IDENTITY}...\Internet Settings\Zones\L" where L is a strange character that displays like a superscript L, As you delete that key javascript will restart working.

Share:
23,732

Related videos on Youtube

Bram Visser
Author by

Bram Visser

Updated on September 17, 2022

Comments

  • Bram Visser
    Bram Visser over 1 year

    I have a problem that just started at work recently and the network manager is certain he did not change anything with the group policy. Anyways, here is a detailed description of the problem.

    My machine is Windows XP SP3, and I use IE8 to browse. We have McAffee anti-virus software that I am unable to configure. I use the following file to test...

    <!DOCTYPE html>
    <html>
      <head>
        <title>Javascript Test</title>
      </head>
      <body>
        <script type="text/javascript">
          document.write("<h1>PASS</h1>");
        </script>
        <noscript>
          <h1>FAIL</h1>
        </noscript>
      </body>
    </html>
    

    When I open this file from the C: drive, it fails every time. If I execute it anywhere else (local/remote web server or on a mapped network drive), it works just fine. When I am simply browsing the Internet, Javascript on web sites works just fine. It is only failing on files running from my C: drive. Additionally, I have had a couple other programmers in the department try this file on their C: drive, and it works fine for them. So I don't believe it is a group policy thing.

    I need to fix this because I do extensive testing from my C: drive, and I am accustomed to doing so. I don't want to get into the habit of moving files to a different drive just to test.

    Things I have tried:

    • Enabled "Allow Active Content to Run Files on My Computer" in Options | Advanced | Security
    • Enabled "Allow Active Scripting" in Options | Security | Custom Level
    • Verified that "Script" was not checked as disabled in Developer Toolbar
    • Added localhost to Trusted Sites in Options
    • Disabled McAffee completely (momentarily, with help from network admin)
    • Used an older DOCTYPE in my test HTML page
    • Re-installed IE8 completely
    • Ran regsvr32 on the JScript.dll
    • Slammed keyboard

    I am sure that there is a setting somewhere that will fix this problem, possibly in the registry. I would not be surprised if it was related to the developer toolbar. At this point I do not know where else to look.

    Can anyone help me resolve this problem?

    EDIT: Regardless of the bounty, this issue is still ongoing.

    • Admin
      Admin over 14 years
      well, it works just fine for me in WinXP/IE8 (as it does for your colleagues) so it's got to be a local problem (and i'm NOT using McAfee :). if you can't configure your security software, have a chat with the IT department.
    • Mark
      Mark over 14 years
      Why not just run it from your local web server? Why does it have to be run from your C: drive?
    • Bram Visser
      Bram Visser over 14 years
      @Molly we tried disabling McAffee completely. No luck. @Mark It doesn't have to. I want it to because it's easier for a quick and dirty test. And it's always worked before so I am very used to doing this.
    • Arjan
      Arjan over 14 years
      IE has always prompted me in the yellow information bar on top of the window to allow JavaScript from "My Computer" (apparently as it will grant access to local resources, which scripts from websites do not get; IE7 screen capture at img.skitch.com/20100106-khkek2wwscdxmak5x8k3y5gax3.png). So, it seems to me that on your computer the warning about running possibly dangerous scripts has disappeared? Maybe you can find something like "reset all warnings"? And in the IE7 options there's even a button to reset all IE settings? And can you collapse/expand local XML files in IE?
    • Arjan
      Arjan over 14 years
      And did those other programmers not get that warning in the information bar either? (So: did the script run without any prompt on their computer?)
    • Bram Visser
      Bram Visser over 14 years
      @Arjan one of them got the prompt, but setting the "Active Content" option in Options removed the prompt.
    • Bram Visser
      Bram Visser over 14 years
      @Arjan Also, disabling this setting on my machine, and running the test file on a network drive does give me the yellow info bar.
    • Arjan
      Arjan over 14 years
      Do all browsers show "My computer" in their status bars? Or do some actually show "Trusted sites" or something similar?
    • Bram Visser
      Bram Visser over 13 years
      I am still having this problem and it is still pissing me off daily!
  • Bram Visser
    Bram Visser over 14 years
    Adding localhost to Trusted Sites does not work. I realize that I can setup a server, and I do use one for my primary development. But sometimes I will just write a quick and dirty test (on occasion, for answering a question on this web site!) and save it on the desktop, where I can easily execute and delete it. I've grown accustomed to doing this, and it works fine on all my other computers except this one. Something is the matter, and there must be a way to correct it.
  • Bram Visser
    Bram Visser over 14 years
    I understand my work-around options, and I have several of them at-hand. However, what I really want to do is figure out why this is not working on this particular machine. As mentioned in my question and in other comments, I have grown quite accustomed to writing quick and dirty Javascript tests on my desktop. I've been doing it since 2000, at least. It's a hard habit to break and it ticks me off when I have to change the way I work just because one particular machine decides to give me a hard time. It's ridiculous and far from ideal. There must be a solution.
  • Admin
    Admin over 14 years
    the problem might very well be related to the McAfee security suite (which you can't configure?). so, again, a virtual machine without McAfee is one quick way to find out. i mean, there is no real trouble-shooting possible if you can't eliminate the main suspect, is there?
  • William Hilsum
    William Hilsum over 14 years
    Could it be version of Windows / Internet explorer? It is since (I think) SP2 of XP that javascript was blocked locally.
  • William Hilsum
    William Hilsum over 14 years
    ... updated - Have you checked for - i50.tinypic.com/29vcx15.jpg
  • Bram Visser
    Bram Visser over 14 years
    @Wil Yes, and I mentioned that in the question. I've included a couple more things I have tried in the question as well.
  • Admin
    Admin over 14 years
    "trying to disable" is a quite strechable expression. are there any identical machines in your company? then have one cloned onto your machine if that is feasible. speaking of cloning, create a full drive image, and then start ripping it apart if you're really interested in the cause. not very cost efficient and i would only do it to satisfy my professional curiousity.
  • Bram Visser
    Bram Visser over 14 years
    Let me rephrase that... using administrative privelages, we completely disabled all McAffee services on my machine and it did not fix the issue. Two colleagues have identical machines as me, and they do not have the problem. Identical is stretching it, because obviously I have my own personal settings stored in my user profile. I have tried signing on to one of those identical machines, and when I do that, everything works fine. Issue is completely localized to this machine, and I can't ghost over it because then I will lose all my local settings for apps like Visual Studio, etc. Thanks :)
  • Admin
    Admin over 14 years
    of course, if they were 100% 'identical' you wouldn't be able to run local java scripts in IE on them :) anyway, i don't know how the cost factor is weighed in your company, but migrating your settings to a clone (after backing up your entire drive) seems to be still the easiest way. as for me, i am unable to reproduce the error (all is well here), so i can only engage in guesswork (which i hate! :).
  • Bram Visser
    Bram Visser over 14 years
    I know it; problems like this typically go unsolved unless they are reproduced. I am trying to re-create the problem on another machine. Thanks anyways :)
  • Bram Visser
    Bram Visser over 14 years
    Darn, I thought this would work, but no dice. The problem still exists. Thanks for the answer, though!
  • jburke
    jburke over 14 years
    did you reboot after?
  • Bram Visser
    Bram Visser over 14 years
    Changing to .hta works, but it does not open in Internet Explorer. I am aware of the work-around options, but I ultimately need to get JS to run on my C: drive within an HTML file.
  • Bram Visser
    Bram Visser over 14 years
    No I did not, but I will try that too.
  • jburke
    jburke over 14 years
    ok, usually the dcom settings won't go into effect untill you reboot. good luck!
  • Bram Visser
    Bram Visser over 14 years
    Tried rebooting, still no luck. Darn :(
  • Goyuix
    Goyuix over 14 years
    An HTA uses the same rendering engine and the same Windows Scripting Host to supply the javascript support as Internet Explorer. Why is it a requirement to open in Internet Explorer? I would argue that while technically it is not launching iexplore.exe - it effectively is running identically to how it would in the browser with more lax security restrictions. If you needed it to potentionally run in other browsers or other operating systems, that would drive the requirement... but I don't see that from your question or comments.
  • Bram Visser
    Bram Visser over 14 years
    Thanks, but the DWORD was already there, and set to 0 :(
  • Bram Visser
    Bram Visser over 14 years
    It does not appear to allow me to add the C: to the trusted sites zone. It gives me some stupid invalid wildcard sequence message. I've compared all the ActiveX settings with my colleagues, and they are identical.
  • Arjan
    Arjan over 14 years
    Nice thought. It's still a workaround of course, but nice idea!
  • AlexV
    AlexV over 14 years
    ...and that don't requre any change to your security policies, IE settings...
  • davidcl
    davidcl over 14 years
    I'm not sure I'd call this a workaround, if it actually solves the poster's problem. Microsoft specifically suggests it: "You should add a MOTW to every HTML document whose contents would be restricted by Internet Explorer's Local Machine zone lockdown security feature. Following are examples of when to insert a MOTW....You need to preview Web pages locally before uploading them to a Web site." --From msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx
  • Bram Visser
    Bram Visser over 14 years
    It works, but it is lame. Thanks :)
  • AlexV
    AlexV over 14 years
    Why it's lame? It's better by far than lowering security of your whole system for just one page (and sometimes it's not even possible). Mark of the Web are here for that and it's the best solution for this kind of "problem" IMO. If there is something lame, it's IE! :)
  • Bram Visser
    Bram Visser over 14 years
    It's lame because: a) it does not solve the problem. b) it essentially forces local content to run in the security for the given web site (web content has less security restrictions than local content...? seems a little backwards to me!). This makes sense for the scenario that davidcl described, but the fact that it works around the issue I am having just makes the situation even more daunting.
  • AlexV
    AlexV over 14 years
    Why do you say it does not solve the problem when your last comment said it worked? Yes web content is "less" secure than local content (at least for JavaScript execution).
  • Bram Visser
    Bram Visser over 14 years
    Solving the problem != conspicuously working around the problem.
  • AlexV
    AlexV over 14 years
    Yeah but I think the "problem" in question is just normal IE and or security software behavior which you can't control as you are non-admin.
  • Bram Visser
    Bram Visser over 14 years
    It is not normal, because none of the other programmers have the problem I have.
  • AlexV
    AlexV over 14 years
    But are you in the same user group as them? Whith the exact same rights? Since you have no control on the rights you have, we can't actually help you more than giving workarounds... Ask your admin to be put in their group to see if it's changing something.
  • AlexV
    AlexV about 13 years
    @kentaromiura: Just a year late, but since the OP problem only occurs when file:// is used, in that particular case it's a perrfectly suitable solution.