你好我想写一个静态网页利用ifrmae将这个网页httpswwwworkermannetai嵌入我的静态网页中标题不能用httpswwwworkermannetai这个网页的标题有什么办法麻烦贴下代码给我
你可以使用JavaScript来修改iframe中的标题,代码如下:
<!DOCTYPE html>
<html>
<head>
<title>My Static Webpage</title>
<meta charset="UTF-8">
<script type="text/javascript">
window.onload = function() {
var iframe = document.getElementById("my-iframe");
iframe.onload = function() {
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
var title = iframeDoc.title;
document.title = "My Static Webpage - " + title;
}
};
</script>
</head>
<body>
<h1>My Static Webpage</h1>
<p>Here is an embedded webpage:</p>
<iframe id="my-iframe" src="https://www.workerman.net/ai"></iframe>
</body>
</html>
这个代码会在页面加载完成后,自动将iframe中的标题加上一个前缀,然后显示在页面的标题栏中。你只需要将代码保存为一个.html文件,然后用浏览器打开即可
原文地址: https://www.cveoy.top/t/topic/gdsi 著作权归作者所有。请勿转载和采集!