期望的脚本标签:
<script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"> </script>
尝试1:
var clientScriptManager = this.Page.ClientScript; if (!clientScriptManager.IsClientscriptincludeRegistered(this.GetType(),"BingMapControl")) { clientScriptManager.RegisterClientscriptinclude( this.GetType(),"BingMapControl","https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"); }
尝试2:
HtmlGenericControl include = new HtmlGenericControl("script"); include.Attributes.Add("type","text/javascript"); include.Attributes.Add("src","https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"); this.Page.Header.Controls.Add(include);
有任何想法吗?
解决方法
Desired script tag:
<script type=”text/javascript”
src=”https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1″>
</script>
实际上,没有.实际上,您想要的脚本标记是:
<script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1"> </script>
你确实想要&被编码为& amp ;.为什么?因为HTML标准是这样说的.例如,参见XHTML 1.0标准的第C.12. Using Ampersands in Attribute Values (and Elsewhere)节:
In order to ensure that documents are compatible with historical HTML user agents and XML-based user agents,ampersands used in a document that are to be treated as literal characters must be expressed themselves as an entity reference (e.g. “
&
“). For example,when thehref
attribute of thea
element refers to a CGI script that takes parameters,it must be expressed ashttp://my.site.dom/cgi-bin/myscript.pl?class=guest&name=user
rather than ashttp://my.site.dom/cgi-bin/myscript.pl?class=guest&name=user
.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。