Asp.net html脚本标记未使用类型javascript<;脚本类型=";text/html">;?

Asp.net html脚本标记未使用类型javascript<;脚本类型=";text/html">;?,asp.net,javascript,html,tags,script-tag,Asp.net,Javascript,Html,Tags,Script Tag,我在一个html页面上查看源代码时遇到了这个问题 <script id="searchItemTemplate" type="text/html"> <# var rows = Math.floor((Model.RecordsPerPage - 1) / 3 + 1); for (var i = 0; i < rows; ++i){ var startIdx = i * 3; var endIdx = startI

我在一个html页面上查看源代码时遇到了这个问题

<script id="searchItemTemplate" type="text/html"> 
    <# var rows = Math.floor((Model.RecordsPerPage - 1) / 3 + 1);
       for (var i = 0; i < rows; ++i){
        var startIdx = i * 3;
        var endIdx = startIdx + 3;
    #>
//etc .... 
</script>

//等等。。。。
我以前从未见过这种情况。什么是脚本
type=“text/html”
。我不知道这是否有区别,但这是在一个.aspx页面上

这是一种稍后要解析和eval()的占位符吗
有人知道这是什么吗
使用过这种方法的人能解释它的好处吗?
具有未知内容类型的脚本元素将被忽略,在这种情况下,浏览器不知道如何执行
text/html
脚本

这是一些JavaScript模板引擎使用的常用技术

另见:


这是我第一次在John Resig的博客文章中看到的一个技巧。它用于保存模板以便以后扩展。浏览器不会尝试执行它

“好处”?嗯,这比直接在Javascript代码中保留字符串要简洁得多。因为Javascript中没有多行字符串,所以定义这样的模板很麻烦

编辑-哈哈,是的,CMS在他的回答中链接了这个博客帖子