[英]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.