到目前为止,明显的区别似乎是你不能使用“script”标签混合html和vbscript@H_301_3@
例如,这没关系@H_301_3@
<% public sub display_literal() %> literal <% end sub %>
<script language="vbscript" runat="server"> public sub display_literal2() response.write "literal2</br>" end sub </script>
http://www.newobjects.com/pages/ndl/alp/asp-structure.htm@H_301_3@
它说@H_301_3@
In classic ASP the script written in the default script language for the page (i.e. the language assumed for the <% %> tags) is executed second – e.g. all the script code in <% %> tags is initialized after all the <SCRIPT RUNAT=SERVER …> scripts. @H_301_3@
但我做了几个测试,无法验证它……@H_301_3@
我问,因为我有一个脚本(我现在没有它),使用< %%>给了我一个错误,将其更改为< script>标签解决了问题,但我想知道为什么….@H_301_3@
解决方法
顺序是这样的: – @H_301_3@
>在< script runat =“server”标记中运行所有脚本,其中指定的语言与默认语言不匹配.这些按文档顺序执行.>运行默认脚本.这意味着执行对响应的隐含写入,其中页面中存在静态内容(不在runat =“server”标记内或在< %%>内)以及< %%>中的任何中间代码再次按文件顺序显然.>在< script runat =“server”标记中找到的全局级别运行任何代码,其中语言与默认脚本语言匹配. 请注意,所有脚本在执行阶段1之前都有一个初始解析,因此可以在阶段3中运行的脚本定义的任何函数都可用于从阶段1调用.@H_301_3@