Detect if browser supports vbscript?

I was hoping I could use a modernizer (or similar) to determine if the browser is capable of vbscript. It does not look like I can.

IE11 recently changed the user agent by removing MSIE and replacing Trident. This was done to make IE more like other browsers according to the html specifications.

I have some old sites that need a browser to support vbscript. I am looking for a way to determine how I can determine if a browser supports vbscript. Some of these sites use classic asp, which makes it difficult to work with.

Ideas? ty Right now, I'm thinking of using javascript to evaluate a user agent, and if it contains msie, then we can assume that it supports vbscript.

+4
source share
2 answers

The shortest way I was able to do this was as follows (maybe 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 is that only vbscript drivers will raise an error for this syntax.

It can be used as follows:

if (supportsVb) {
    // Make a vbscript call
} else {
    // Make a javascript call
}
+5
source

See progressive improvement .

Create a page to enable "VBScript is not supported."

Then add VBScript to convert it (adding and removing DOM elements) to the "VBScript supported" version.

+1
source

Source: https://habr.com/ru/post/1534167/


All Articles