StackOverflow代码段不允许“在新标签页中打开”

时间:2019-12-21 03:10:22

标签: html iframe stack-overflow

来自我的answer。该代码可在jsfiddle上正常运行,但不适用于Stackoverflow的代码段。 “有效”是指我希望它在新标签上打开https://www.google.com/ ,这就是that question的OP想要的。

我在Stackoverflow代码段上运行时打开控制台,这是错误消息:

enter image description here

即使在Stackoverflow片段(使演示更具吸引力)上,有什么方法可以使我的答案正常工作吗?

document
.querySelectorAll("a.fresh")
.forEach(a => {
  a.setAttribute("target", "_blank")
});
a.fresh {
  text-decoration: none;
}
<a class="fresh" href="https://www.google.com/">link1</a>
<a class="fresh" href="https://www.google.com/">link2</a>

0 个答案:

没有答案
相关问题