<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text">
<button>确认</button>
<script>
var input = document.getElementsByTagName('input')[0];
var button = document.getElementsByTagName('button')[0];
button.onclick = function () {
if(input.value.length != 0) {
document.title = input.value;
}
}
</script>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考