2009-06-03 72 views
5

我正在尝试使用jQuery PrettyPhoto,并且由于某种原因它没有通过ID变量..如果有人遇到过这个问题并知道解决方案,那太棒了!下面的代码:jQuery PrettyPhoto将ID传递给iframe

<a href="/store-item-details?id=5&iframe=true&width=800&height=530" 
    rel="prettyPhoto[iframes]" 
    title=""> 
    <img src="/images/store/thumbs/'.$item->image.'" 
     alt="'.$item->name.'" 
     width="100" 
     border="0" /> 
</a> 

这里的链接(用漂亮的图片,点击缩略图之一)

http://www.photographicpassions.com/shop?view=products&category=1

,这里是从标签直接链接:

http://www.photographicpassions.com/store-item-details?id=1&iframe=true&width=800&height=530

请帮忙! :)

回答

6

你的问题在于prettyPhoto本身。该插件假设(在iframe的情况下)该URL中没有其他重要参数,并在解析出高度和宽度后删除所有参数。

这是jquery.prettyPhoto.js的非注音版本的一个片段。注意第三行,它删除了movie_url中的问号之后的所有内容。

}else if(pp_type == 'iframe'){ 
     movie_url = $caller.attr('href'); 
     movie_url = movie_url.substr(0,movie_url.indexOf('?')); 

     pp_typeMarkup = '<iframe src ="'+movie_url+'" width="'+(correctSizes['width']-10)+'" height="'+(correctSizes['height']-10)+'" frameborder="no"></iframe>'; 
    } 

我不确定你有多强悍,但如果你评论出第三条线,它会为你工作。 (你可能会想重新缩小后看到:http://fmarcia.info/jsmin/test.html

}else if(pp_type == 'iframe'){ 
     movie_url = $caller.attr('href'); 
     // movie_url = movie_url.substr(0,movie_url.indexOf('?')); // commented out to allow other attributes to be passed along. 

     pp_typeMarkup = '<iframe src ="'+movie_url+'" width="'+(correctSizes['width']-10)+'" height="'+(correctSizes['height']-10)+'" frameborder="no"></iframe>'; 
    }