gpt4 book ai didi

jquery - 通过 ".content()"访问 iframe 内容没有成功

转载 作者:行者123 更新时间:2023-12-01 08:20:08 25 4
gpt4 key购买 nike

http://api.jquery.com/contents/

据说,您可以通过contents()方法访问iframes DOM。我剪切并粘贴了代码,将 id 更改为页面上的 iframe,然后选择一个非常简单的 div,这是 iframe 中唯一的一个。它没有找到它。我已经成功地操纵了 iframe 本身的 css,所以我很确定一切都是正确的。这也全部在文档就绪条件中。

相关页面在这里 http://syndex.me/tagged/belgium

希望有人能够阐明这种方法的工作原理。

谢谢

$("#tumblr_controls").css({
position : 'fixed',
top : 'auto',
bottom : '15px',
}); //works
$("#tumblr_controls").contents().find("div").css("right","auto"); //doesnt work
$("#tumblr_controls").contents().find("div").css("left","0"); //doesnt work

请注意,我认为您必须登录 tumblr 才能看到有问题的控件。

<iframe src="http://assets.tumblr.com/iframe.html?10&amp;src=http%3A%2F%2Fsyndex.me%2F&amp;lang=en_US&amp;name=syndex&amp;brag=0" scrolling="no" width="330" height="25" frameborder="0" style="right: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; background-color: transparent; overflow-x: hidden; overflow-y: hidden; position: fixed; top: auto; bottom: 15px; z-index: 1000007; " id="tumblr_controls">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="x-dns-prefetch-control" content="off">
<link rel="icon" href="http://assets.tumblr.com/images/favicon.gif?2" type="image/gif">
</head>
<body style="background-color:transparent; margin:0px; padding:0px;" onload="var image1 = new Image(); image1.src = 'http://assets.tumblr.com/images/iframe_like_alpha.png';
var image2 = new Image(); image2.src = 'http://assets.tumblr.com/images/iframe_like_active_alpha.png';">

<style>
img {
margin-left: 3px;
}
</style>

<div style="position:absolute; top:3px; right:3px; white-space:nowrap; height:20px;">

<form action="/follow" method="post" style="display:block; float:left;" onsubmit="_gaq.push(['_trackEvent', 'Iframe', 'Follow', 'syndex');">
<input type="hidden" name="form_key" value="4d9WHkMln7qxbqRkkU1FJ51jYk">
<input type="hidden" name="id" value="syndex">
<input type="image" src="http://assets.tumblr.com/images/iframe_follow_alpha.png?663" style="width:58px; height:20px; border-width:0px; display:block;
margin-left:3px; cursor:pointer;" alt="Follow">
</form>

<a target="_top" href="http://www.tumblr.com/dashboard"><img src="http://assets.tumblr.com/images/iframe_dashboard_alpha.png?663" alt="Dashboard" style="height:20px;
width:81px; border-width:0px; display:block; float:left; cursor:pointer;"></a>

</div>

</body></html>

</iframe>

最佳答案

您无权访问 tumblr_controls 框架的内容,因为它来自另一个域。

更多信息:

关于jquery - 通过 ".content()"访问 iframe 内容没有成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7868869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com