【问题标题】:HTML Font and Bold not rendering in IE 11 , but works in chrome - dynamically from javascriptHTML Font 和 Bold 不在 IE 11 中呈现,但在 chrome 中工作 - 从 javascript 动态
【发布时间】:2015-11-26 06:35:28
【问题描述】:

我的代码在 Chrome 中渲染得很好,但在 IE 11 中却没有显示

IE 11 中的问题 - 开发者工具 F12

<li><ul>11/25/15 : <a href="http://server1/coc-home/#/tips/2?paginatePage=1" target="_parent">Dev Test in Supervisor Title</a> By: CBOWER</ul></li>

在 Chrome 中工作 - 开发者工具 F12 输出

<li><ul>11/25/15 : <font color="red"><b>NEW - </b></font><a target="_parent" href="http://server1/coc-home/#/tips/2?paginatePage=1">Dev Test in Supervisor Title</a> By: CBOWER</ul></li>

所以基本上在 IE 11 浏览器中,javascript 完全不渲染字体和粗体

<font color="red"><b>NEW - </b></font>   -- missing in IE rendering

我的 Javascript 循环在 Chrome 中呈现的代码

//add red New if date created last 10 days
var dt = new Date(formattedDateString);
var today = new Date();
var newText = "";
var dateDiffDays = Math.ceil((Math.ceil(dt.getTime() - today.getTime())) / (1000 * 3600 * 24));

if (dateDiffDays >= -10 && dateDiffDays <= 10) {
   console.log('NEW - date within 10 days');
   newText = "<font color='red'><b>NEW - </b></font>";
} else {
   console.log('OLD');
   newText = "";
}

strResult += "<li><ul>" + formattedDateString + " : " + newText + "<a target='_parent' href='http://" + dochomenotlocal + "/doc-home/#/tips/2?paginatePage=1'>" + news.title + "</a> By: " + news.createdby + "</ul></li>";

更新:

这个 Fiddle 表明它在 IE 11 中可以很好地渲染 javascript 和 css

http://jsfiddle.net/bthorn/yr009hwd/1/

【问题讨论】:

  • 不要使用字体标签...它已被弃用多年。
  • @epascarello - 当然我知道要使用 css,但是 IE 没有显示它的原因是什么?
  • 不,不是,原因是你生成的html无效。

标签: javascript html css google-chrome internet-explorer


【解决方案1】:

您生成的 HTML 无效

<li><ul>text

UL 需要有一个 li 作为孩子,你有 textNodes 和其他元素。

【讨论】:

  • 我把顺序改成了
    • text
    如果这就是你的意思,但那不起作用,IE 仍然显示
  • 我之前确实继续创建了一个 css 类,然后我使用了在 chrome newText = "NEW - ";
  • 以为 IE 11 可能没有以同样的方式评估 Date 对象,所以基于我之前在 jsfiddle 中创建的代码,我在 IE 中尝试了它,它在 chrome、FF 和 IE 11 中都可以正常工作@ 987654321@
  • 很好地了解 html
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-13
  • 2014-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多