我正在尝试使用 jQuery PrettyPhoto,但由于某种原因它没有传递 id 变量..如果有人以前遇到过这个问题并且知道解决方案,那就太棒了!代码如下:
<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
请帮忙! :)
最佳答案
你的问题在于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>';
}
关于jQuery PrettyPhoto 将 ID 传递给 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/944587/