IE中动态构建的Javascript src属性错误
Controller
public ActionResult GetCategories()
{
var htmlText = new StringBuilder();
var scriptText = new StringBuilder();
htmlText.Append("Hello world");
scriptText.AppendFormat("document.write({0});", htmlText.ToString());
var content = new ContentResult();
content.Content = scriptText.ToString();
return content;
}
View
<script src="/Home/GetCategories" type="text/javascript" language="javascript"/>
在 FF 上运行良好,但在 IE 中运行不佳。
Controller
public ActionResult GetCategories()
{
var htmlText = new StringBuilder();
var scriptText = new StringBuilder();
htmlText.Append("Hello world");
scriptText.AppendFormat("document.write({0});", htmlText.ToString());
var content = new ContentResult();
content.Content = scriptText.ToString();
return content;
}
View
<script src="/Home/GetCategories" type="text/javascript" language="javascript"/>
It runs well on FF, but not in IE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
script
标记需要一个结束标记才能兼容。 IE 在这方面实际上遵守了标准,而 FF 则更加宽容。将您的视图更改为:A
script
tag needs a closing tag to be compliant. IE actually obeys the standard in this respect while FF is more forgiving. Change your view to: