Javascript无法控制日志或继续

时间:2017-06-14 17:43:49

标签: javascript html

我想知道为什么第二个控制台日志没有显示在浏览器中:

    var metas = document.getElementsByTagName('meta');
    for (var i=0; i<metas.length; i++) {
        if (metas[i].getAttribute("property") == "_escaped_fragment_") {
            var escapedFragment = metas[i].getAttribute("content");
            console.log('Fragment: ' + escapedFragment);
            var myNode = document.getElementById("rootPanel");
            myNode.innerHTML = '';
            console.log('rootPanel cleared');
            window.history.pushState("_escaped_fragment_", "", "?f=" + escapedFragment);
        }
    }

当第一个出现时。

1 个答案:

答案 0 :(得分:0)

是的,似乎工作正常。

&#13;
&#13;
var metas = document.getElementsByTagName('meta');
for (var i = 0; i < metas.length; i++) {
  if (metas[i].getAttribute("property") == "_escaped_fragment_") {
    var escapedFragment = metas[i].getAttribute("content");
    console.log('Fragment: ' + escapedFragment);
    var myNode = document.getElementById("rootPanel");
    myNode.innerHTML = '';
    console.log('rootPanel cleared');
    window.history.pushState("_escaped_fragment_", "", "?f=" + escapedFragment);
  }
}
&#13;
<meta property="_escaped_fragment_">foo</meta>
<div id="rootPanel">bar</div>
&#13;
&#13;
&#13;