简体   繁体   English

尝试创建一个显示asp-classic变量值的消息框或警报

[英]Trying to create a messagebox or alert which displays the value of an asp-classic variable

I found this post and tried the first suggestion, and while it will display what I need it to, I suddenly get lots and lots of javascript errors. 我找到了这篇文章,并尝试了第一个建议,尽管它会显示我需要的内容,但突然出现了很多JavaScript错误。 It's generating about 30 expected end of statement errors. 它产生约30条expected end of statement错误。 The message box works great though, which is why I'm trying to figure out if there's another solution to pop-up the value of an ASP variable. 消息框效果很好,这就是为什么我试图找出是否存在另一种弹出ASP变量值的解决方案的原因。 I'm trying to get it to display inside of an ASP function. 我正在尝试使其显示在ASP函数内部。

Got it! 得到它了!

I ended up using this: 我最终使用了这个:

    %><script language=javascript>
    var temp = '<%=message%>';
    alert(temp);
    </script><%

I don't know why I didn't think to do that before! 我不知道为什么我以前没想到要这样做!

I had to work with some legacy code recently and had this same problem. 我最近不得不使用一些遗留代码,并且遇到了同样的问题。 This will work as well if the variable was previously defined: 如果该变量是先前定义的,这也将起作用:

Response.Write "<script language='JavaScript'>alert('The value is " & variable_name& "');</script>"

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

相关问题 在 asp-classic 中启用 javascript - enabling javascript in asp-classic 带有JavaScript图表的ASP经典 - asp-classic with a javascript chart 尝试使用ASP-classic和jQuery根据数据库的结果自动选择一个下拉选项 - Trying to automatically select a dropdown option based off of a result from a database using ASP-classic and jQuery 如何在asp.net中的数组中获取值(或以asp-classic为佳) - How to get value in array in asp.net ( or asp-classic would be better) 创建一个显示警报的通用函数,并接受要在警报中显示的值作为输入 - create a generic function that displays an alert, and accepts as input the value that is to be displayed in the alert 使用javascript在ASP-classic网站中字体颜色不会改变 - Font color won't change in ASP-classic site using javascript 在IIS5.1和ASP-classic下获取HTTP PUT请求的参数? - Parameter retrieval for HTTP PUT requests under IIS5.1 and ASP-classic? asp-classic不起作用Internet Explorer中的Request.ServerVariables(“ HTTP_REFERER”) - asp-classic Not working Request.ServerVariables(“HTTP_REFERER”) in Internet Explorer 如何在 ASP-Classic 或 WSH 环境中使用来自 VBScript 的 Javascript OO 类? - How can I use Javascript OO classes from VBScript, in an ASP-Classic or WSH environment? 在“ JavaScript警报消息框”的“确定”按钮上分配一个值 - Assign a value on OK button of JavaScript Alert Messagebox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM