【发布时间】:2011-07-22 05:23:30
【问题描述】:
几分钟前,Google 推出了一个新徽标,但它在我的计算机上非常滞后。 我想继续使用当前的谷歌风格,但没有标志。 徽标元素的当前 ID 是“hplogo”。 所以我在 iframe 中创建了一个包含 google 的网页,我想使用 jquery 删除该元素。
<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>
我认为它不起作用,因为它不是同一个域。有没有办法解决这个问题?
【问题讨论】:
-
根据 jQuery 文档:“如果 iframe 与主页位于同一域中,.contents() 方法也可用于获取 iframe 的内容文档。”
-
这在另一个帖子中得到了回答。检查stackoverflow.com/questions/364952/…
-
<iframe width="100%" height="500" src="http://www.google.com/custom?q=&btnG=Search"></iframe>或只是click here。