在iframe的父级中显示jquery prettyPhoto灯箱

时间:2010-02-01 21:59:33

标签: jquery iframe parent

我知道此问题已经讨论过,但我似乎无法让它发挥作用。我在该页面上有一个带有iframe的主html页面。我正在使用jquery prettyphoto,当我点击iframe中的链接时,我想知道如何在父窗口中显示灯箱?

请在下面输入我的代码:

母版页

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Master Page</title> 
</head> 

<body> 
 <iframe src="iframe.html" width="300" height="300px" frameborder="0"></iframe> 
</body> 
</html>

iFrame页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>iframe</title>

<style type="text/css" media="screen">
    @import url("assets/css/infotech-iframes.css");
    @import url("assets/css/infotech-popup.css");
</style>

<script src="assets/js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/jquery.popup.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <a href="assets/images/screenshots/campaign-setup-lg.png" rel="prettyPhoto[gallery]"><img src="assets/images/screenshots/campaign-setup-sm.gif" /></a>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto();
    });
</script>
</body>
</html>

由于

1 个答案:

答案 0 :(得分:0)

您将需要编辑prettyPhoto.js源以将所有内容推送到父框架中。我首先修改对

的引用
appendTo($('body'))

类似

appendTo($('body', window.parent))