题
我使用jquery。2.5.3我想知道我如何可以得到光盒显示的父窗口的一种框架时的图像链接的内部框架是选择的?
这是我的代号:
页面:
<html>
<head>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen"/>
<script src="js/jquery.prettyPhoto.js" type="text/javascript"></script>
</head>
<body>
<a href="animage.jpg" rel="prettyPhoto">
<img src="animage.jpg" height="200" width="200"/>
</a>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>
</body>
当我加载了这页上的其自己的收藏作品的罚款。
框架码:
<html>
<head>
</head>
<body>
<iframe src="inner.html"/>
</body>
</html>
然而,当我加载的页面点击图像链接页面,是在面,我希望的灯箱显示在父窗口并不在框架.
解决方案
试试这个选择: $("#myid", top.document)
顶部。文献讲述的选择目标的身份识别码元素 存在最上面的文件(你的父母页)。为了这个 要工作。必须载入文件,这是看过的 面.
资料来源: http://groups.google.com/group/jquery-en/browse_thread/thread/5997ef4a60a123af?pli=1
编辑
"确定"的唯一途径,这将工作是:
删除以下代码从你真正的网页(inner.html,一个包含在框架):
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $("a[rel^='prettyPhoto']").prettyPhoto(); });
现在你的面页,增加:
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen"/> <script src="js/jquery.prettyPhoto.js" type="text/javascript"></script>
还添加以下JS码:
$(function() { $("iframe").contents().find("a[rel^='prettyPhoto']").click(function() { $(this).prettyPhoto(); return false; } ); });
这应该做的把戏,但它将只作为浮动框架页,并且不直接从内实页。
其他提示
发现这个某处
<base target="_parent" />
把它IFRAME头部内
我解决了这个问题,使用的数据的副本的IFRAME。 看到主页脚本代码: 注:在我的代码有启动的画廊,画廊是不可见的,图像ID为“btngaleria”的图像。
$("#iPrincipal").load(function(){
$("#iPrincipal").contents().find("#btngaleria").click(function() {
var temp=$("#iPrincipal").contents().find("#galeria").html();
$("#galeria").html(temp);
$("#galeria:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',slideshow:4000, autoplay_slideshow: true});
$("#galeria li:first a").click();
});
});
iframe的HTML代码是:
<iframe src="home.asp" name="iPrincipal" id="iPrincipal" frameborder="0" width="100%" height="540"></iframe>
和在接收的复制的数据页的底部的DIV:
<div id="falso" style="display:none; visibility:hidden"><ul id="galeria" class=""></ul></div>
我制成试验FF和IE和正常运行。
代码变化,我是:
- 加入一个新的true/false设置,开始在线18。即
displayIframeContentsInParent: false
, 在围绕线92
if(theGallery)
如果块的检查,如果新的设置已经被设置为真正的和如果是这样,搜索的框架内为更多的图像的画廊:if(settings.displayIframeContentsInParent) { $("iframe").contents().find('a[rel*='+theGallery+']').each(function(i) { if($(this)[0] === $(link)[0]) setPosition = i; images.push($(this).attr('href')); titles.push($(this).find('img').attr('alt')); descriptions.push($(this).attr('title')); }); }
在周围线的125在开放的功能:在
if($.browser.msie && $.browser.version == 6)
如果别的方框,添加下面还藏组合框在框架:if(settings.displayIframeContentsInParent) { $("iframe").contents().find('select').css('visibility','hidden'); }
最后,关于围绕线300在关闭功能:在
if($.browser.msie && $.browser.version == 6)
如果别的方框,添加下面的作组合框在该框架可见了:if(settings.displayIframeContentsInParent) { $("iframe").contents().find('select').css('visibility','visible'); }
当然,使用漂亮的照片现在你将需要设置新的设置为真所以,它将搜索的嵌入内容为其他图像来显示即
$("a[rel='prettyphoto']").each(function() {
$(this).prettyPhoto(displayIframeContentsInParent: true);
});
我发一个链接到这些变化的支持。论坛因此我们希望,这些变化将得到纳入。来源。
我与此完成:
<script type="text/javascript">
$('iframe').load(function(){
$(this).contents().find("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>
它看起来通过主网页上的所有I帧。 iframe的代码内的JQuery不是必需的。
这是所有关于你尝试访问它之前的iFrame的内容必须加载:
http://grasshopperpebbles.com/ajax/using-jquery -to存取iframe的内容/