【问题标题】:how to remove the #prettyphoto from the url如何从网址中删除#prettyphoto
【发布时间】:2013-05-17 13:04:07
【问题描述】:

我正在使用 prettyphoto 媒体 wordpress 插件(版本 3.1.4)。 它对我来说工作正常,但我的问题是,当我单击任何图像并在灯箱中打开时,url 中有一些额外的标签,例如:#prettyPhoto[landscaping]/0/ 这就是为什么 url 看起来像:www.myssite.com/#prettyPhoto[landscaping]/0/

我们怎样才能删除这个额外的标签。 这是我的 jquery.prettyPhoto.js 文件中的代码:

function setHashtag(){
        if(typeof theRel == 'undefined') return; // theRel is set on normal calls, it's impossible to deeplink using the API
        location.hash = theRel + '/'+rel_index+'/';
    };

    function clearHashtag(){
        if ( location.href.indexOf('#prettyPhoto') !== -1 ) location.hash = "prettyPhoto";
    }

【问题讨论】:

  • 如果有人使用 prettyphoto 媒体 wordpress 插件,那么在插件自定义选项卡设置部分,您可以取消选中允许 prettyPhoto 更新 url 以启用深度链接。 [默认值:true]。它会起作用。

标签: javascript jquery tags wordpress prettyphoto


【解决方案1】:

我昨天遇到了同样的问题,我很确定我在 stackoverflow 中找到了答案……我访问了很多网站、论坛……所以我不记得我在哪里得到了确切的答案。

不管怎样,我正在开发 Dreamweaver,但我猜 WP 中的代码类似。

您需要做的是在调用 prettyPhoto 时将 deeplinking 属性指定为 false

这是我的代码:

    $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto({
            theme:'light_rounded',
            social_tools:false,
            deeplinking:false,      
    });
});

我是 js 的菜鸟,但我希望这会有所帮助:)

【讨论】:

  • 这绝对有帮助,这是我们可以隐藏丑陋的 URL 并从任何页面返回的一种方式,结果是实际的 uRL,而不是图片弹出窗口。这是正确答案
【解决方案2】:
  $(document).ready(function() {
      $("a[rel^='prettyPhoto']").prettyPhoto({
          theme: 'light_rounded',
          social_tools: false,
          deeplinking: false
      });
  });

使用 deeplinking:false 从 url 中删除 #prettyphoto

【讨论】:

    猜你喜欢
    • 2012-11-05
    • 1970-01-01
    • 2021-03-17
    • 2020-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多