javascript如何获取网页获取Session变量
我正在尝试在 javascript 中使用 Session 变量。
不幸的是,我尝试了一些帖子建议但没有成功。
我到处都看到这个例子。
var userName = '<%= Session["UserName"] %>'
但这不起作用,至少对我来说。我想做的如下。
var qrdataString = "<qr-code data=" + "XL" + ' <%= Session["style"] %>' + "></qr-code>";
document.getElementById("styleqr").innerHTML = qrdataString;
使用上面出现的单引号只会返回字符串,因为
<%=Session["xUID"]%> in the alert that I use to show me the returned value
使用双引号会给我 - 意外的标记:字符串文字 - 或意外的标记标识符。
谢谢
I'm trying to use a Session variable in javascript.
I have tried a number of post suggestions without success unfortinately.
I see this example all over the place.
var userName = '<%= Session["UserName"] %>'
However that is not working, at least for me. What I am trying to do is as below.
var qrdataString = "<qr-code data=" + "XL" + ' <%= Session["style"] %>' + "></qr-code>";
document.getElementById("styleqr").innerHTML = qrdataString;
Using Single quotes where they appear above just returns the string as
<%=Session["xUID"]%> in the alert that I use to show me the returned value
Using Double quotes give me either - unexpected token: string literal - or unexpected token identifier.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一段时间的摸索,并偶然发现了下面的文章,我终于成功了。
完整结果
HTML
JAVASCRIPT
HTML
After messing around for a while, and also stumbling on the following article, I have managed to get this going.
FULL RESULT
HTML
JAVASCRIPT
HTML