Tapestry 5 支持 vbscript 吗?
我被要求通过 vbscript 片段“嗅探”用户的 Windows 用户名,但无法在 Tapestry (5.1.0.5) 应用程序中使其正常工作。
Tapestry 似乎试图将 vbscript 解释为 javascript,因此失败了。
vbscript 片段(如下)嵌入到一个组件中,该组件又作为多区域更新的一部分有条件地加载到区域内。
伪 tml:
<page>
<t:zone>
<t:if>
<t:mycomponent>
<vbscript />
vbscript:
<script type="text/vbscript" language="vbscript">
Dim shell
set shell = createobject("wscript.shell")
set env = shell.environment("process")
set field = document.getElementById("windowsLoginField")
if field is nothing then
alert("no field")
else
field.value = env("username")
end if
</script>
我知道这应该只适用于 IE,但是其他浏览器应该正常失败(不运行脚本)。
当区域在应该呈现 vbscript 的状态下重新加载时,我在 firebug 中收到以下错误:
missing ; before statement
Dim shell
这是因为脚本正在由 prototypejs 评估:
evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},
有谁知道一种方法来避免原型评估此脚本,以便它可以通过并作为vbscript执行吗?
我注意到没有 @IncludeVbScriptLibrary 注释...
谢谢,p。
I've been asked to 'sniff' users' windows username via a vbscript snippet and am having trouble getting this to work in the tapestry (5.1.0.5) application.
It seems tapestry is trying to interpret the vbscript as javascript and therefore failing.
The vbscript snippet (below) is embedded within a component which is in turn loaded conditionally inside a zone as part of a multizoneupdate.
pseudo tml:
<page>
<t:zone>
<t:if>
<t:mycomponent>
<vbscript />
vbscript:
<script type="text/vbscript" language="vbscript">
Dim shell
set shell = createobject("wscript.shell")
set env = shell.environment("process")
set field = document.getElementById("windowsLoginField")
if field is nothing then
alert("no field")
else
field.value = env("username")
end if
</script>
I am aware that this should only work for IE, however other browsers should fail gracefully (not run the script).
When the zone is re-loaded in a state where the vbscript should be rendered, I get the following error in firebug:
missing ; before statement
Dim shell
This is because the script is being evaluated by prototypejs:
evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},
Does anyone know of a way to avoid prototype evaluating this script so that it can make it through and be executed as vbscript?
I notice there is no @IncludeVbScriptLibrary annotation ...
thanks, p.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tapestry 从原型继承了这个问题。一种解决方案是修补原型 extractScripts 和 evalScripts,以便它们在看到 vbscript 时执行您想要的操作。
这段代码可以工作(在 IE7 和 Chrome 中测试),但它可以变得更灵活(例如,关闭类型而不是语言)
Tapestry inherits this problem from prototype. One solution is to patch the prototype extractScripts and evalScripts so that they do what you want when they see vbscript.
This code works (tested in IE7 and Chrome), but it could be made more flexible (keys off of type and not language for instance)