How to remove annoying "#!prettyPhoto/0/" string from URL?
  • I just noticed that prettyPhoto keep appeding a string to the url similar to "#!prettyPhoto/0/", which is annoying because if you refresh the page AFTER you closed the lightbox or went to another page and then clicked back in your browser the PP popup opens up again because the url already contains the "#!prettyPhoto/0/".
    Does anyone know how to turn this off? Previous versions of prettyPhoto didn't apend this string to the url.
  • I believe you remove deep linking.

    deeplinking: false
  • Right on, that was it! Thanks.
  • thanks for this post!
  • Very Thanks...

    It's very usable.
  • fineputinpogo... you have made my day.
  • Hey guys, what's the easy way of keeping the deep linking feature but change the url so that its something other than !prettyPhoto ?

    Would be greatly appreciated. Cheers.
  • I was facing this problem, diagnoses the pretty photo library and i find the solution for that problem:-

    Go it not prettyphoto.js
    find the function:-


    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+'/';

    //showing query string in url stoped by ashiq

    And comment that all it will perfectly fix your problem

    Ashiq Mustafa Shah
  • Hi,
    the issue described in the first post (lightbox opens again on refresh) is solved with version 3.1.3.
    In the function call you can use "deeplinking: false" to disable the display of the deeplink-url in the adressbar of your browser (deeplinking will still be working (if you know the link)).
    So, actually there is no need to manipulate the js file to achiev this.
  • The #!prettyPhoto is appearing in the URL bar now, with 3.1.3, when deep linking is off/flase
  • that's true, there is a "!prettyPhoto" added to the url even when deeplinking is switched off since 3.1.3 but the re-opening of the lightbox after refreshing the site is fixed!
    This new url-behaviour seems to be an earlier bug-fix "Fix scroll when hashtag is clear" and is already questioned in the bug-reports of prettyPhoto.
  • So now we still have to endure "!prettyPhoto" as part of the URL even though deeplinking is false?

    What's the point of adding this to the URL?
  • the point of adding this is probably "Fix scroll when hashtag is clear"... (dunno!)
    In the js in "function clearHashtag()" you can remove it, but no idea what than will go wrong with the scrolling...
  • Quote cs: 'the point of adding this is probably "Fix scroll when hashtag is clear"... (dunno!)'

    Yeah, I already got that!

    But I don't know what "fix scroll" even means as I don't recall seeing any scrolling issues with previous versions. Exactly, what was this bad scrolling behavior and what did the user have to do to trigger it?
  • Fix it by reverting back to v3.1.2
  • I had the same problem, but it seemed like an easy fix, here is my updated code for the clearHashTag() function:

    function clearHashtag(){url=location.href;hashtag=(url.indexOf('#!prettyPhoto'));if(hashtag > 0)location.hash="!prettyPhoto";}

    Here is the original:

    function clearHashtag(){url=location.href;hashtag=(url.indexOf('#!prettyPhoto'))?true:false;if(hashtag)location.hash="!prettyPhoto";}

    that url.indexOf('#!prettyPhoto') always evaluates to true if it's missing because it gives a -1. I removed that true:false part, and just put in an evaluation if hashtag > 0.

    This works for me and seems safe enough.
  • I just did this... Got rid of all the "deeplinking" stuff...

    function getHashtag(){
    return false;

    function setHashtag(){

    function clearHashtag(){
    return false;
  • Even with deeplinking: false I still get the additional hashtag after closing out so I switched from version 3.1.3 to 3.1 in the meantime which seems to remove this issue.
  • I wanted the hashtags when an item was clicked but I didn't want the !prettyPhoto when it was closed. So, I just cracked open the prettyPhoto.js and changed this:


    to this:


    Now when I click an item it shows a nice little hash tag for deep linking with Twitter. But, when it's closed it just has the #. I'm happy with the end result.
  • Worked for me too. Thanks!
  • bigevilbrain, where exactly did you put those three functions?
  • I think we must implement a configuration variable to specify what to see instead of "!prettyPhoto" hash and another one to choose whether to see the #!prettyphoto hash tag when closing the modal window or not...
    Does anybody know if a public social repository (as github) to help the develpment of prettyPhoto?

    i just found this:
    I think it would be a great starting point to provide suggestion and submit improvements...
  • There is such option - deeplinking, but it's broken in 3.1.3
  • Using a method above, I was easily able to edit the JS to remove the "!prettyPhoto" from the URL and it seemed to work.

    Then in Explorer (maybe all others too), I discovered the "scroll issue" as mentioned previously.

    Just an FYI- The Scroll Issue: You're scrolled down the page someplace and invoke prettyPhoto. When you exit prettyPhoto, you will return (scroll up) to the top of the page instead of staying where you were when you invoked it. Leaving "#!prettyPhoto" in the URL solves this issue. It's ugly but it works.

    Deep-linking is still turned off but '#!prettyPhoto' must stay in the URL to prevent this annoying 'return to top of page' issue.
  • Works perfect with 3.1.3 -- No more hashtags and no deeplinking.

    What I did in jquery.prettyPhoto.js :

    1. Put the --> deeplinking:false

    2. Replace --> clearHashtag(){url=location.href;hashtag=(url.indexOf('#!prettyPhoto'))?true:false;if(hashtag)location.hash="!prettyPhoto";}

    by --> clearHashtag(){url=location.href;hashtag=(url.indexOf('#!'))?true:false;if(hashtag)location.hash="";}

    And you can still use the old links if you want to link a picture or w/e.

  • Giiyom, your solution is not bad but the '#' is still present in the URL. This is a real issue et to fix the bug properly, just add two characters ">0" as follow:

    Replace --> clearHashtag(){url=location.href;hashtag=(url.indexOf('#!prettyPhoto'))?true:false;if(hashtag)location.hash="!prettyPhoto";}

    by --> clearHashtag(){url=location.href;hashtag=(url.indexOf('#!prettyPhoto')>0)?true:false;if(hashtag)location.hash="!prettyPhoto";}

    That's all folks !
  • @butchewing Thank's so much. I was beginning to think this otherwise devastatingly awesome plug-in was only for metrosexual posers! Try explaining to a corporate client why the lightbox forced an append of a brainless URL token like "prettyPhoto", with no option to change it, and even the "deeplinking" property in the options not removing it in all of it's self-promoting lameness. I really appreciate you taking the time to publish your code snippet here!
  • @votrewebmaster : that works! thanks!
  • guys won! worked very well, I'm using this:

    -- deeplinking:false

    -- clearHashtag(){url=location.href;hashtag=(url.indexOf('#!prettyPhoto')>0)?true:false;if(hashtag)location.hash="!prettyPhoto";}

  • In 3.1.4 Production it is corrected!
  • Thanks !! It works with setting deeplinking: false
  • Great, can anyone help with facebook liking the wrong image?
  • So I thought I had this figured out with the above solutions (I'd get a # in my URL, but I was fine with that...) and then I noticed I now get the scrolling issue mentioned (when further down in a page, once you close the modal box it pops back to the top of the page instead of staying where you were)

    Anyone find a way to solve this while still keeping the deeplinking?
  • for anyone else running across this, I found a solution on another page here that worked for me. This will only work if you are ok with additional characters in the URL, but here is a way to replace #!prettyPhoto in the URL with your own custom string. You'll end up with the new custom string at the end of your URL now, but this way it can just be #pp or make it #jdp if your site is "john doe photography" or whatever you like....
  • (ps - the above is for those wanting to keep deeplinking and fix the scroll problem)
  • can someone please help me with fixing the scrolling problem. When i tried to scroll the modal window, the background also scrolls and totally it messes up giving a shaky feeling on the screen. someone please provide me with a solution .......
  • hi guys, I'm going crazy. When I share a photo of my prettyphoto gallery, in the activities of my facebook post has the preview of Internet Explorer Warning orange, someone would be kind enough to explain this problem and maybe fix it?
    Thank you very much

    I loaded the bug with wetranfer here:
  • hi, how to remove the "this w" line that appears when the photo gets loaded in the overlay...Pls help me out
    thank you
  • Hi could someone please tell me where I locate the code on a wordpress site to set deep thinking to false.
  • In jquery.prettyPhoto.js

    function clearHashtag(){
  • Does anyone have a fix for this in Version 3.1.5? I don't see the clearHashtag function in the js
  • Hello All,

    Even if I set the deeplinking to false after I open a picture, the link of the page changes, and something like this gets added to the end: #prettyPhoto[pp_gal]/0/

    the problem it causes is that, after i close the pictures, when i press the back button of the browser, it doesnt go back because of that additional section in the end of the link. i have to click on the back button several times to work, depending on how many pictures i viewed with prettyphoto.

    How can I fix this issue. If the customers view 6 pictures they will have to click the back button 6 times in order to get back which is really bad user experience... Any suggestions are appreciated???

  • Adding the following worked for me:
    deeplinking: false
  • Hi jeffshead,

    It already has such kind of row and I change it to false. Should I add deeplinking: false additionally somewhere else?

    It is pretty annoying and if it cant be fixed I will have to remove the hole prettyphoto module due to this issue.... :(

  • bgfriend,

    Hi! Yeah, you are almost there! Open up jquery.prettyPhoto.js and hit Ctrl+F and search for "deeplinking" and it should show you the default, "deeplinking:true."

    Change that true to false. Save it, and you should be golden! prettyPhoto is too good to throw out! :)
  • Hi Kasej,

    I have changed the value of the deeplinking feature from true to false in the both files: jquery.prettyPhoto.js and vqmod_pretty_photo_152x_153x-154x.xml. The deeplinking is set to false however it stills change the url and after the user close the prettyphote galery he/she must hit the back button several times in order to return on the previous page which is really bad experience from user point of view. You can see it here:

    If open the pictures and hit severtal times the next button of the Prettyphoto and then close it and than try to navigate back to the main category and see what is happening... The url is changing but you must hit the button the same number as you hit the next button of the prettyphoto while seeing the pictures. It is terrible...

    Any suggestions are appreciated as always. The module is great however such kind of issue can cause a lot user frustration and at the end leave the particular site due to this functionality.


  • When looking at the code for your site, deeplinking is still set to true in the jquery.prettyPhoto.js file.

    May I ask what editor you are using to build the site?

    If I read you correctly, you manually opened up jquery.prettyPhoto.js and changed the value, saved that file and replaced the one on the server with the new one. Correct?
  • Hi,

    hmm, i actually change it through the cPanel file manager at my hosting. There is a option to change the particular file and the code there directly and save the changes after it. Once you refresh the page it is suppose to take effect. However I tried your suggestion to download the file and edit it through Notepad++. After I upload it the result is the same... I do not know what am I doing wrong :( Any suggestions are appreciated as always!

    Best Wishes,
  • Just to confirm I am changing the file jquery.prettyPhoto.js which is present under the following directory:


    The another file is under vqmod/xml/vqmod_pretty_photo_152x_153x-154x.xml

  • Still shows as true when I examine the script. :(

    I'm not sure what to say... That property has to be changed in the script files manually. I had the same issue when I tried to call up the file and change the script in the source code.

    When you saved the file in Notepad, you kept the *.js extension? I don't see any other files it could be confusing itself with or duplicates on the server.

    This is the filepath I see the deeplinking property in:

    Is this the one you are editing?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter