2010-08-24 101 views
0
<html> 
    <iframe src="iWantToBeTheParent.html" /> 
</html> 

我覺得這是一個JavaScript的任務,這將是很好處理與htaccess的重定向雖然因爲我的代碼的iframe中,我尋找一種方法,從iframe源內部啓動,這會使iframe url加載爲父項。最好的SEO方法

我只能訪問iframe源頁面的html。
是否也可以發送301 HTTP重定向?

編輯:如果需要,我可以使用php打印出iframe頁面的url作爲JavaScript變量。

+0

您是否有權訪問iframe的源代碼或父代的源代碼? – Hello71 2010-08-24 16:24:51

+0

我希望我做到了。不,我不知道:) – Mohammad 2010-08-24 16:30:52

回答

0

你可以嘗試一些javascript:

<script type="text/javascript"> 
    <!-- 
     if (top.location!= self.location) { 
      top.location = self.location.href 
     } 
    //--> 
</script> 

禮貌的: http://usablelayout.com/articles/automatically-break-out-iframe

這將設置頂層位置(主頁),可在JavaScript是位於頁面的位置(在iframe中)。

+0

有誰知道我們是否可以在執行上述重定向的同時用JavaScript設置HTTP頭? – Mohammad 2010-08-24 16:30:34