简体   繁体   English

ASP.net C# 从 javascript 调用 vbscript

[英]ASP.net C# calling vbscript from javascript

I have this basic page:我有这个基本页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Teste1.aspx.cs" Inherits="Testes.Teste1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title></title></head>
<body>
    <form id="form1" runat="server">
    <input id="clickMe" type="button" value="clickme" onclick="getText();" />
    </form>
<script type="text/vbscript" language="vbscript">
Function createText()
    createText = "A"
End Function
</script>
<script type="text/javascript"  language="javascript">
function getText(){
    var vbobj;
    vbobj = createText();
    alert("VBScript text = " + vbobj);
}
</script>
</body>
</html>

But this is not working, I'm getting the following message但这不起作用,我收到以下消息

Unhandled exception at line 27, column 5 in http://localhost:59632/Teste1.aspx 0x800a1391 - JavaScript runtime error: 'createText' is not defined http://localhost:59632/Teste1.aspx 0x800a1391 中第 27 行第 5 列的未处理异常 - JavaScript 运行时错误:'createText' 未定义

I hope you know VBScript works only in IE.我希望您知道 VBScript 仅适用于 IE。 Try to put this meta tag in your head section:尝试将此元标记放在您的头部部分:

<head>
    <meta http-equiv="x-ua-compatible" content="IE=10">
</head>

It helped me as I was using IE 11 edge mode, in which VBScript isno longer supported .当我使用 IE 11 边缘模式时,它对我有所帮助,其中不再支持VBScript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM