html script tag not using type javascript lt;script type=quot;text/htmlquot;gt;?(html 脚本标签未使用类型 javascript lt;script type=quot;text/htmlgt;gt;?)
问题描述
我在一个 html 页面上查看源代码并遇到了这个
I was checking out the source on an html page and came across this
<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 页面上.
I have never seen this before. What is script type="text/html"
. I don't know if it makes a difference but this was on a .aspx page.
这是某种稍后要解析和 eval() 的占位符吗?
有谁知道这是什么?
使用过这种方法的人可以解释一下好处吗?
推荐答案
简单地忽略具有未知内容类型的脚本元素,在这种情况下,浏览器不知道如何执行 text/html
脚本.
Script elements that have an unknown content-type are simply ignored, in this case, the browser doesn't know how to execute a text/html
script.
这是一些 JavaScript 模板引擎常用的技术.
It's a common technique used by some JavaScript templating engines.
另见:
- JavaScript 微模板
- JavaScript 模板引擎
这篇关于html 脚本标签未使用类型 javascript <script type="text/html>>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:html 脚本标签未使用类型 javascript <script type="text/html>>?


基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01