2011-07-22 134 views
3

谷歌幾分鐘前出來了一個新的標誌,而且在我的電腦上非常不穩定。 我想繼續使用當前的Google風格,但沒有徽標。 徽標元素的當前id是'hplogo'。 所以我做了一個網頁,其中包含谷歌在iframe中,我想要刪除該元素使用jQuery。JQuery訪問iframe元素

<head> 
     <script src="jquery.js" type="text/javascript"></script> 
     <script type="text/javascript"> 
     $(document).ready(function(){ 
      $("#google").height($(window).height()); 

      setTimeout(function(){ 
       $("#google").contents().find("#hplogo").remove()); 
      }, 3000); 
     }); 
     </script> 

</head> 
<body style="margin:0px;"> 
<iframe id="google" style="border:none;width:100%;overflow:auto;" src="http://www.google.com/"> 
</iframe> 
</body> 
</html> 

我認爲它不工作,因爲它不是相同的域。有沒有解決的辦法?

+0

根據jQuery文檔:「.contents()方法也可用於獲取iframe的內容文檔,如果iframe與主頁位於同一個域中的話。」 –

+0

這是在另一篇文章中回答的。檢查http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe –

+0

'