Reputation: 3157
I was hoping i could use modernizer (or similar) to determine if a browser was capable of running vbscript. It doesn't look like i can.
Recently IE11 has modified the user-agent removing MSIE and replacing with 'Trident'. This was done to make IE look more like other browsers in compliance with html specs.
I have a number of old sites that require the browser to support vbscript. I am looking for a way to determine how I can determine if the browser supports vbscript. A number of these sites use classic asp which makes it more difficult.
Ideas? ty Right now, I am thinking of using javascript to evaluate the user agent and if it contains msie then we can assume it does support vbscript.
Upvotes: 5
Views: 1005
Reputation: 13974
The shortest way I was able to do this was as follows (might be a cleaner way, but I don't know VBScript, I just know Modernizr).
var supportsVb = (function() {
var supports = false;
var vb = document.createElement('script');
vb.type="text/vbscript";
try {
vb.innerText="Err.Raise";
} catch (e) {
supports = true;
}
return supports
})()
The idea being that only vbscript engines will raise an error for that syntax.
It can be used like this:
if (supportsVb) {
// Make a vbscript call
} else {
// Make a javascript call
}
Upvotes: 4
Reputation: 943569
Build the page to give then "VBScript is not supported" experience.
Then add VBScript to transform it (adding and removing DOM elements) to the "VBScript is supported" version.
Upvotes: 1