运行结果尺寸: 300 x 150
x
 
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>单击按钮创建一个 BASE 元素。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.createElement("BASE");
  x.setAttribute("href", "https://www.w3schools.cn");
  document.head.appendChild(x);
  document.getElementById("demo").innerHTML = "您现在已经在文档的 HEAD 部分创建了一个 BASE 元素。";
}
</script>
</body>
</html>
×

报个问题: