javascript - JScript - VBScript TypeName function for ActiveXObjects -


is there way determine activexobject type variable in jscript? vbscript has typenamefunction i've not been able find suitable counterpart in jscript. i'm familiar typeof , instanceof operators neither 1 return object specific data.

the reason i'm inquiring work project. if possible, need avoid using vbscript. below of project requirements cannot deviate from:

  • jscript code part of hta.
  • hta hosted internet explorer 8.
  • all computers running windows 7 (32 bit).

the closest i've been able jscript true/false value:

var regex = new activexobject('vbscript.regexp'); regex instanceof activexobject; // returns true 

with vbscript, however, typename function returns object interface name:

dim regex set regex = createobject("vbscript.regexp") typename(regex) ' returns iregexp2 

here complete hta made test previous results:

jstesting.hta

<!doctype html> <html> <head> <title>jscript testing</title> <meta http-equiv='x-ua-compatible' content='ie=8' /> <script language='jscript'>     new function () {         var width = 350, height = 120;         var left = (screen.availwidth - width) / 2;         var top = (screen.availheight - height) / 2;         resizeto(width, height); moveto(left, top);     }     window.onload = function () {         var regex = new activexobject('vbscript.regexp');         jstest.onclick = vbstest.onclick = function () {             var id = event.srcelement.id;             var typename = (id === 'jstest') ? jstypetest : vbsproc;             output.innertext = typename(regex);         };     };     function jstypetest(obj) {         return (obj instanceof activexobject) ?         'activexobject' : 'unknownobject';     } </script> <script language='vbscript'>     dim vbsproc     set vbsproc = getref("vbstypetest")     function vbstypetest(obj)         vbstypetest = typename(obj)     end function </script> <style type='text/css'>     span {         margin-top: 10px;         font: 10pt courier new;     } </style> </head> <body>     <button id='jstest'>jscript</button>     <button id='vbstest'>vbscript</button>     <hr>     <span>vbscript.regexp object = </span>     <span id='output'></span> </body> </html> 


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -