Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要从外部javascript文件::函数中调用vbscript函数_Javascript_Function_Vbscript_External - Fatal编程技术网

我需要从外部javascript文件::函数中调用vbscript函数

我需要从外部javascript文件::函数中调用vbscript函数,javascript,function,vbscript,external,Javascript,Function,Vbscript,External,到目前为止,我得到的是: 此函数不直接位于html页面中,而是位于外部js文件“main.js”中 function createVBScript(){ var script=document.createElement('script'); script.type='text/vbscript'; script.src='vb/fldt.vbs'; document.getElementsByTagName('head')[0].appendChild(script); } vbs文

到目前为止,我得到的是:

此函数不直接位于html页面中,而是位于外部js文件“main.js”中

function createVBScript(){
 var script=document.createElement('script');
 script.type='text/vbscript';
 script.src='vb/fldt.vbs';
 document.getElementsByTagName('head')[0].appendChild(script);
}
vbs文件包含:

<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
 Function VBGetSwfVer()
    MsgBox "Hello there"    
 End Function
// -->

这就是我目前想要做的如何从main.js调用VBGetSwfVer()

这是个坏主意。
VBScript仅受IE支持;你的页面永远无法在Firefox上工作

在Internet Explorer中,您应该能够像调用任何其他函数一样简单地调用该函数。

但是,您应该将函数移植到Javascript。

所有函数都将在全局范围内可用,因此您可以像调用常规Javascript方法一样调用它们

包含vbscript的另一种方法是使用execScript

window.execScript('Class NixProxy\n' +
'    Private m_parent, m_child, m_Auth\n' +
'\n' +
'    Public Sub SetParent(obj, auth)\n' +
'        If isEmpty(m_Auth) Then m_Auth = auth\n' +
'        SET m_parent = obj\n' +
'    End Sub\n' +
'    Public Sub SetChild(obj)\n' +
'        SET m_child = obj\n' +
'        m_parent.ready()\n' +
'    End Sub\n' +
'\n' +
'    Public Sub SendToParent(data, auth)\n' +
'        If m_Auth = auth Then m_parent.send(CStr(data))\n' +
'    End Sub\n' +
'    Public Sub SendToChild(data, auth)\n' +
'        If m_Auth = auth Then m_child.send(CStr(data))\n' +
'    End Sub\n' +
'End Class\n' +
'Function GetNixProxy()\n' +
'    Set GetNixProxy = New NixProxy\n' +
'End Function\n', 'vbscript');

@slaks,在调用vbsript之前,我已经确定了用户代理。因此,是的,它在firefox中永远不会工作,但如果最终用户有ie以外的东西,它甚至不应该尝试

@肖恩,这很有趣,我会参考的

我的解决办法是:

将其包含在index.html的标题中

<script type="text/javascript" src="js/main.js"></script>
<script type="text/vbscript" src="vb/fldt.vbs"></script>

然后,仍然在index.html标题中,编写一个小的内联javascript支持函数

<!--[if !IE]>-->
<script languge="javascript">
     function jsCallToVB(i) {
          var val = VBGetSwfVer(i);
   return val;
     }
</script>
<!--<![endif]-->

函数jsCallToVB(i){
var val=VBGetSwfVer(i);
返回val;
}
然后在我的外部main.js文件中,我调用
jsCallToVB(i)