我想知道为什么第二个控制台日志没有显示在浏览器中:
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);
}
}
当第一个出现时。
答案 0 :(得分:0)
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;