我试图在 2 秒(2000 毫秒)后动态更改页面标题。
这是我尝试过的代码:
<!DOCTYPE HTML>
<html>
<head>
<title>Before</title>
</head>
<body onload="updateTitle">
<script>
var title = document.getElementsByTagName('title');
function updateTitle() {
//Here is some kind of delay (of 2 seconds). I have tried setTimeout(), setInterval() and delay()
title.innerHTML = "After";
</script>
Dummy Content for Body
</body>
</html>
如何修改它,以便 2 秒后页面标题发生变化?