jQuery PrettyPhoto 将 ID 传递给 iframe

标签 jquery jquery-plugins

我正在尝试使用 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/

相关文章:

javascript - 在 ES6 中创建 HTML/JS "plugin"- 如何刷新 DOM 节点

javascript - fengyuanchen jQuery cropper 插件-如何获取裁剪的 Canvas

javascript - 将相同的 div 内容与另一个 div 内容切换

javascript - 在我的购物 list 应用程序中,每件商品有多个按钮,而不是每件商品只有一个按钮?

javascript - 获取 jquery ui 小部件的所有实例的引用?

jquery - 容器内的底部 float div(如 Facebook 消息中) - 采取 2

jquery - Jrails 和 jquery-rails 一起吗?

javascript - 在 nuxt.js View 中使用 jquery

javascript - 禁用 turobolinks 来服务页面特定的 javascript

javascript - 导入一张图像和一个文本文件——选择图像时显示文本文件内容