38

I tried the following HTML page with two scripts:

<html>
  …
  <body>
    <script type="text/javascript">
      alert ('Javascript');
    </script>
    <script type="text/vbscript">
      msgbox "Vbscript"
    </script>
  </body>
</html>

On Windows 8.1 preview + Internet Explorer 11, the JavaScript worked, the VBScript did not.

On (Windows 8 + IE10), (Windows 7 + IE9), the two scripts worked.

I did not find any information about the end of VBScript support in Internet Explorer 11, did you?

6 Answers 6

62

The IE team has been trying to retire VBScript for years.

http://msdn.microsoft.com/en-us/library/windows/apps/Hh700404.aspx indicates that support was removed from the ExecScript API. http://msdn.microsoft.com/en-us/library/ie/dn384057(v=vs.85).aspx explains that it's removed from IE11 Edge mode in the Internet Zone.

If you add the following to your HEAD tag, your VBScript will run:

<meta http-equiv="x-ua-compatible" content="IE=10">
7
  • 1
    IS that the only way exists, Are there any other way to run VBScript in IE11.
    – zaree
    Commented Aug 6, 2014 at 12:20
  • 1
    @zaree: You haven't explained why you're interested. Based on MSDN, moving a given site to a non-Internet Zone would also work.
    – EricLaw
    Commented Aug 6, 2014 at 20:30
  • 12
    On StackOverflow, if you have a question, you click the Ask Question button at the top of the page.
    – EricLaw
    Commented Aug 7, 2014 at 16:32
  • 1
    @called2voyage: On which OS (and what is the exact IE version) did you try?
    – EricLaw
    Commented Oct 30, 2015 at 15:26
  • 1
    @EricLaw Windows 7 Enterprise SP1, Internet Explorer 11.0.9600.18059 Commented Oct 30, 2015 at 15:43
14

It actually very simple.

Only IE 10 and older supports VBScript. However you can easy change compatibility mode on IE 11 to IE 10 and it works perfectly fine.

I had the same issue: an old web site developed in 2004 using ASP and VBScript and the following procedure was the solution for me.

In order to change compatibility mode in IE 11 :

  1. Press F12 to open developer tools
  2. In left toolbar scrool down until you see "Emulation" settings page
  3. Change Document Mode from default ("Edge") to 10
  4. Enjoy your VBScript
1
  • 1
    This is only a temporary solution. It will work fine, but if someday you want to use a functionality that is not compatible with IE10, it will not work anymore. but it's what I use also!
    – Rafiki
    Commented Mar 23, 2015 at 13:32
7

Actually I just had the same issue and found the resolution for myself. I also tried the way that EricLaw described but that didn't work for me. Here is what I found:

Open your website, go to Tools --> Compatibility View Settings, and then click Add (the website you are on should show in the form automatically), and you should be able to see the result.

2
  • 1
    Which version of IE are you using? Commented Apr 30, 2015 at 14:03
  • 1
    I am using IE 11. Here is the link from MS (msdn.microsoft.com/library/…) but you know there are smart people everywhere know cool tricks. Maybe there is another way to get around...
    – ian0411
    Commented May 1, 2015 at 15:54
5

Another possible solution is to use HTA files I was struggling to save a tool that use simple HTML interface to survive our company migration from IE8 to IE11, and after a lot of investigation, this simple solution was found: rename files from file.html to file.hta

it is then openned by Microsoft HTML application host, which still support VBscript.

Downside is that not all CSS format are supported, but it's really easy to use this solution

3

This is probably part of Microsoft's effort to make IE11 look like a standard browser.

IE11 removes all existing ways to check whether it's IE (other than actual specific feature detection that IE11 doesn't support yet).

The idea is that IE now works enough like a standard browser that any existing code with special cases for IE should no longer apply.

Checking for VBScript support is simply one of those obsolete checks that Microsoft wants to prevent.

2
  • 3
    Not really, they have explicitly said they include Trident in the user agent so you know its IE - they just don't want to trigger all the workarounds for old versions of IE
    – Ben Adams
    Commented Aug 20, 2014 at 0:33
  • 3
    You're both right in that we're pushing developers to focus on feature detection instead of browser sniffing, especially for newer versions of IE where in most cases, your code should just work. Along with changes to the UA string, other features like DXfilters and conditional comments have been deprecated as IE has continued to mature into a standards-based direction.
    – Rey Bango
    Commented Aug 20, 2014 at 23:44
3

Try this HTA code:

<html><head>
<HTA:APPLICATION 
            ID              = "testHTA" 
            APPLICATIONNAME = "testHTA"
            VERSION         = "0.1"
            NAVIGABLE       = "yes"
            SHOWINTASKBAR   = "yes" 
            SINGLEINSTANCE  = "yes" 
            WINDOWSTATE     = "normal"
            BORDER          = "normal" 
            BORDERSTYLE     = "normal"
            INNERBORDER     = "no"    
            CAPTION         = "yes" 
            MINIMIZEBUTTON  = "yes"
            MAXIMIZEBUTTON  = "yes"
            SYSMENU         = "yes" 
            SCROLL          = "yes" 
            SCROLLFLAT      = "yes"    
            CONTEXTMENU     = "yes"
            SELECTION       = "yes"
        />
</head>
  <script language="javascript" type="text/javascript">
      function MyJsAlert() {
        alert('Hello world!  Opening notepad now...');
      }
  </script>
<script language="VBScript" type="text/vbscript">
MyJsAlert() 'executes javascript
' Create a Windows Shell object
set oShell = CreateObject("WScript.Shell")
oShell.CurrentDirectory = "c:\CAMEO\webapps\"
oShell.run("c:\windows\system32\notepad.exe")
</script>
</body></html>

Save the above code as an HTA file (i.e., test.hta), and launch in IE. This code mixes javascript and vbscript, and works in IE 11.

Not the answer you're looking for? Browse other questions tagged or ask your own question.