【发布时间】:2021-04-20 07:02:55
【问题描述】:
如何使用javascript从<object>标签更改网页标题?
此代码来自 main.html,其中包括 <object>
<html>
<head>
<title>main title</title>
</head>
<body>
<h1>home</h1>
<div>
<object type="text/html" data="home.html"></object>
</div>
<script src="script.js"></script>
</body>
</html>
在 home.html 中,我想通过单击按钮将 main.html <title> 标记更改为 home 标题
此代码来自我的 home.html
<html>
<body>
<button onclick="home();">change main title</button>
<script src="script.js"></script>
</body>
</html>
这是我的 javascript 代码
function home() {
window.parent.title = "home title";
}
【问题讨论】:
标签: javascript html