答案 0 :(得分:1)
获取title
的{{1}}非常简单:
iframe
如果要在加载var iframe = document.getElementById("iframeId");
var iframeTitle = iframe.contentDocument.title;
时获取title
的值,请执行:
iframe
document.getElementById("iframeId").onload = function() {
var iframeTitle = document.getElementById("iframeId").contentDocument.title;
}
值现已存储在title
变量中。
之后,您可以使用此变量替换当前页面上的标题值。
iframeTitle
如果您要将此代码插入html文件,请在if (document.title != iframeTitle) {
document.title = iframeTitle;
}
元素中的内容后添加以下代码。
<body>