javascript - 如何从网址中删除#prettyphoto

标签 javascript jquery tags wordpress prettyphoto

我正在使用 prettyphoto media wordpress 插件(版本 3.1.4)。 它对我来说工作正常,但我的问题是当我点击任何图像并在灯箱中打开时,url 中有一些额外的标签,如:#prettyPhoto[landscaping]/0/这就是为什么 url 看起来像:www .myssite.com/#prettyPhoto[美化环境]/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";
    }

最佳答案

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

无论如何,我正在使用 Dreamweaver,但我猜 WP 中的代码类似。

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

这是我的代码:

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

我完全是 js 菜鸟,但我希望这对您有所帮助:)

关于javascript - 如何从网址中删除#prettyphoto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16692439/

相关文章:

javascript - Internet Explorer 中不显示 Dojo 工具提示

javascript - jQuery 获取第一个元素的高度

javascript - 如何在 Firefox 扩展中使用 jQuery

java - Android Studio 无法识别 < 和 > 标签

javascript - 在 Durandal 中插入脚本标签

javascript - if/else 循环执行两个条件

javascript - 如何在 node.js 中获取所有 memcached 数据?

javascript - 在带有打印对话框的 javascript 中打开一个新窗口?

javascript - javascript 中的正则表达式匹配可以匹配等于运算符后面的任何单词吗?

python - Google App Engine ndb 中的分层标签