2011-04-09 49 views
2

我有一個由提供程序設置的域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> 

任何想法?

+0

我非常懷疑這是否可能 - 它們在不同的領域。 – pimvdb 2011-04-09 21:03:57

回答

3

你不行。

瀏覽器顯示加載到頂層框架的頁面的fav圖標。

加載到該頁面內的框架中的頁面無法修改該頁面(same origin policy),因此無法使用JS添加任何favicon數據。

解決方案是獲得至少一半體面的託管。