Vb脚本不适用于Chrome或Firefox - 仅适用于Internet Explorer [英] Vb script not working on Chrome or Firefox - only on Internet Explorer

查看:306
本文介绍了Vb脚本不适用于Chrome或Firefox - 仅适用于Internet Explorer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中编写了VBScript,但这只是在IE浏览器上运行,而不是在Chrome / Firefox上运行。我需要一个VBScript库用于我的代码。这个代码将如何在Chrome和Firefox上工作。我的代码是

 < SCRIPT LANGUAGE =VBScript> 
Sub clickHandler()
sP = Window.Event.SrcElement.ID
如果Left(sP,1)=M则
Set oC = Document.All(C & Mid(sP,2))
如果oC.Style.Display =none则
oC.Style.Display =
否则
oC.Style。 Display =none
End If
Set oC = Nothing
End If
End Sub
< / SCRIPT>


解决方案

客户端VBScript代码 em>适用于IE浏览器。



Chrome和Firefox,更符合标准,期望Javascript客户端代码



它看起来像你的点击处理程序隐藏/显示的东西。这在使用JQuery的Javascript中是很容易实现的,例如,当它被点击时,它应该隐藏'elementid':

$ p $ < script src =// code.jquery.com/jquery-1.11.0.min.js\"></script>
< script>
$(document).ready(function(){
$('#elementid')。click(function(){
$(this).hide();
});
});
< / script>


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>

这篇关于Vb脚本不适用于Chrome或Firefox - 仅适用于Internet Explorer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆