我有一个域parent.example,由提供者设置,用于将“带遮罩”转发给child.example。这意味着URL“ parent.example”保留在地址栏中,并且child.example的内容使用框架集显示。
我想添加一个自定义图标。
到目前为止,我已经在child.example页面上尝试过:
<script type="text/javascript">
var link = document.createElement("link");
link.type = "image/x-icon";
link.rel = "shortcut icon";
link.href = "http://www.child.example/img/favicon.ico";
parent.getElementsByTagName("head")[0].appendChild(link);
</script>
但是这不起作用。
parent.example的HTML是:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>My Title</title></head>
<frameset rows="100%,*" border="0">
<frame src="http://child.example" frameborder="0" />
<frame frameborder="0" noresize />
</frameset>
<!-- pageok -->
<!-- 07 -->
<!-- -->
</html>
有什么想法吗?
您不能。
浏览器显示加载到顶层框架的页面的收藏夹图标。
加载到该页面内部框架中的页面无法修改该页面(same origin policy),因此它无法使用JS添加任何图标图标数据。
解决方案是至少获得像样的托管。
如果您的域名是name.com,则可以在URL掩码中添加收藏夹图标这是迄今为止我发现唯一将favicon添加到被屏蔽的URL的注册商。遵循本指南-https://www.name.com/support/articles/206283127-Adding-favicons-in-masked-forwarding