使用Jquery PrettyPhoto移除URL中的#prettyphoto

4

我使用的是3.1.4版本的prettyphoto。(http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/) 我想从URL中删除 "#prettyphoto[iframe]/number/"。我已将deeplinking设置为false,但这并没有帮助。我明白可能是以下功能的问题:

function getHashtag(){url=location.href;hashtag=(url.indexOf('#prettyPhoto')!==-1)?decodeURI(url.substring(url.indexOf('#prettyPhoto')+1,url.length)):false;return hashtag;};
function setHashtag(){if(typeof theRel=='undefined')return;location.hash=theRel+'/'+rel_index+'/';};
function clearHashtag(){if(location.href.indexOf('#prettyPhoto')!==-1)location.hash="prettyPhoto";}

有什么想法吗?

2
+1. 在URL中添加#prettyphoto真是太烦人了! - Jayden Lawson
4个回答

10

这是我的代码,它对我有效:

    <script type="text/javascript" charset="utf-8">
      $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto({
        social_tools:false,
        deeplinking:false});
      });
    </script>

1
3.1.5版本将可用。
(function($){$.prettyPhoto={version:'3.1.5'};
$.fn.prettyPhoto=function(pp_settings){pp_settings=jQuery.extend(
{.. deeplinking: false; ...}  

1

这对我有效:

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

这段代码位于jquery.prettyPhoto.js文件底部。
b) 还有另一种方式,可以在jquery.prettyPhoto.js文件开头设置deeplinking: false
我指的是这里:
(function($){$.prettyPhoto={version:'3.1.4'};$.fn.prettyPhoto=function(pp_settings){pp_settings=jQuery.extend({.. deeplinking: false; ...}

希望我有所帮助。

请给我更多细节,Manindra。 - Pascut
我已经按照你提到的所有步骤完成了,但是我无法摆脱URL中的#prettyphoto标签。我也使用的是3.1.4版本。 - Manindra Singh
请使用Pastebin或类似的工具,并向我展示您的代码,我将尝试通过编辑来帮助您。 - Pascut

0

这样的东西可行吗?

(function($) {
    console.log('check');

    $.prettyPhoto = {
        version : '3.1.5'
    };

    $.fn.prettyPhoto = function(pp_settings) {
        pp_settings = $.extend({
            deeplinking : false
        });
    };

    $("a[rel^='prettyPhoto']").prettyPhoto();

})(jQuery);  

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接