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?
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">
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 :
Press F12 to open developer tools
In left toolbar scrool down until you see "Emulation" settings page
Change Document Mode from default ("Edge") to 10
Enjoy your VBScript
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.
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
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.
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.
Related
I wrote VBScript in my project, but this is only working on IE and not chrome/firefox. I need a VBScript library for my code. How will this code work on chrome and firefox. My code is
<SCRIPT LANGUAGE="VBScript">
Sub clickHandler()
sP = Window.Event.SrcElement.ID
If Left(sP, 1) = "M" Then
Set oC = Document.All("C" & Mid(sP, 2))
If oC.Style.Display = "none" Then
oC.Style.Display = ""
Else
oC.Style.Display = "none"
End If
Set oC = Nothing
End If
End Sub
</SCRIPT>
Client-side VBScript code only works on IE.
Chrome and Firefox, being more standards compliant, expect Javascript client-side code
It looks like your click handler is hiding/displaying something. This is quite easily achievable in Javascript with JQuery, eg this should hide 'elementid' when it is clicked:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(){
$('#elementid').click(function(){
$(this).hide();
});
});
</script>
VBScript only works in Internet Explorer
There is a Google extention called "IE Tab" which when used, will allow the VBScript to work as if it were running under IE. It will also allow the "style" attribute to work correctly.
You won't be able to use the functions of Internet Explorer on any other browser, you can only navigate using .url files or this script:
set objApp=createobject("Shell.application")
objApp.Shellexecute"chrome.exe", "www.google.com","","",1
'Or if you want to use internet explorer 11, you can download and activate vbscript in it
Recently we migrated to latest version of application which allows the user to open application in any browser.
Earlier it use to support Only IE browsers.
After migration many users still open the application in old browser.
Since the application is very slow in IE browser.We are looking for a solution that will automatically open the URL/Login Page in Chrome browser when user opens in IE browser.
i.e., when a user open URL in IE browser it automatically open the same URL in Google chrome browser.
Google Chrome Legacy Browser support allows this. Under the "Hosts to open in Alternative Browser" policy, put in an entry for the site you want to force to open in Chrome, preceding it with an "!". Example:
!https://www.somesitetoopeninChromeonly.com.
If i understand it correctly, the users open a page in IE and when they click an url on that page, it will open that URL in Chrome.
I guess, you can't do this. You can use target="_blank" to open a new tab in the same browser.
If you want to open a link from an application in chrome and not in IE, you can change the default browser to chrome. Click on Start, type the "default app settings" and change the default browser to chrome.
I think the best solution is to let the user open Google Chrome manually by informing about it.
It is possible however, to make a document called "chrome.hta" for example, with the contents shown below, and then link to it on another page. (This will only work in Internet Explorer, not Edge)
<script type="text/javascript" language="javascript">
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
var website = "http://example.com/";
oShell.ShellExecute(commandtoRun, website, "", "open", "1");
window.close();
</script>
The user now has to press "open" and "allow" after they click the link referring to the .hta file.
Now, on the page where you link to the .hta document, you can make the page detect the browser and adjust the link accordingly:
<a id="link" href="example.com">My Application</a>
<script>
if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
document.getElementById("link").href = "example.com/chrome.hta";
</script>
A bit late, but we have two different solutions for this:
We use a javascript: link to use ShellExecute to run a small exe helper application that checks if Chrome is installed, and if it is, open Chrome to the URL parameter, optionally with switches (e.g. --use-system-default-printer and on shared logon PCs, --incognito). This requires configuring special permissions for the site in Internet Options|Security.
Now we can also use the microsoft-edge: protocol to open sites in Edge.
You could also install your own protocol for opening sites in Chrome but you would need a helper application to re-write the URL. I have one written to add microsoft-edge-private: to open links in Edge in InPrivate mode.
To open the webpage in Microsoft Edge you can try the below code.
TEST
I wrote VBScript in my project, but this is only working on IE and not chrome/firefox. I need a VBScript library for my code. How will this code work on chrome and firefox. My code is
<SCRIPT LANGUAGE="VBScript">
Sub clickHandler()
sP = Window.Event.SrcElement.ID
If Left(sP, 1) = "M" Then
Set oC = Document.All("C" & Mid(sP, 2))
If oC.Style.Display = "none" Then
oC.Style.Display = ""
Else
oC.Style.Display = "none"
End If
Set oC = Nothing
End If
End Sub
</SCRIPT>
Client-side VBScript code only works on IE.
Chrome and Firefox, being more standards compliant, expect Javascript client-side code
It looks like your click handler is hiding/displaying something. This is quite easily achievable in Javascript with JQuery, eg this should hide 'elementid' when it is clicked:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(){
$('#elementid').click(function(){
$(this).hide();
});
});
</script>
VBScript only works in Internet Explorer
There is a Google extention called "IE Tab" which when used, will allow the VBScript to work as if it were running under IE. It will also allow the "style" attribute to work correctly.
You won't be able to use the functions of Internet Explorer on any other browser, you can only navigate using .url files or this script:
set objApp=createobject("Shell.application")
objApp.Shellexecute"chrome.exe", "www.google.com","","",1
'Or if you want to use internet explorer 11, you can download and activate vbscript in it
I recently discovered my vbscript code on an intranet site has been running in IE 8 Compatibility Mode by default because it's on the intranet.
Now the below code works great in IE8 compatibility mode but throws an error if ran in any compatbility mode higher than 8. Help me out please! :) Pretty please?
The error given in IE's developer console is: 'test' is undefined"
Here's the code:
<html>
<head>
<title>Test VBScript Code</title>
</head>
<script language="VBScript">
Sub test
MsgBox "Hello World!"
End Sub
</script>
<body>
<input type="button" value="TEST" onclick="test">
</body>
</html>
IE9 has tighter security and has disabled the running of VBScript in the browser by default.
Here are simple steps to turn on or turn off VBScript in your Internet Explorer:
Follow Tools-> Internet Options from the menu
Select Security tab from the dialog box
Click the Custom Level button
Scroll down till you find Scripting option
Select Enable radio button under Active scripting
Finally click OK and come out
To disable VBScript support in your Internet Explorer, you need to select Disable radio button under Active scripting.
i would like to run .exe files on my computer from my website,
example:
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
}
</script>
<input type="button" value="Run Notepad" onclick="RunFile();"/>
I googled this and its seems its only possible in IE so i wonder if its possible to do this in all browsers with some sort of application like BF3 or something, a handler of some sort .dll or whatever they use.
I will not abuse this, i can assure you i will only use it for my personal usage and with some friends. I want a html file that can open desktop icons.
The ActiveXObject is not part of HTML DOM nor JavaScript/ECMAScript standard. It is only available for Microsoft Internet Explorer (MSIE). MSIE for Mac might also lack support of ActiveXObject since ActiveX is Window platform originated.
There is no way to launch local applications from web pages. As you've no doubt surmised, it's far too easy to abuse.