Search code examples
javascriptjqueryurlpopupcolorbox

Open Colorbox with a unique URL in the location bar


I have a page that opens a Colorbox pop-up when a link is clicked. When this happens the URL in the location bar stays the same. I want this URL to change so I can link visitors directly to the Colorbox pop-up without guiding them to click on the link instead. This page illustrates what I'm trying to accomplish.

So when you look in the URL location bar you see the URL stated above. When you close the pop-up the URL changes to: http://www.uu.nl/daretoexcel/#. Again when you open an other window the URL changes to something similar. So I know how to open Colorbox and I got it working. It's just that the URL in the location bar stays the same all the time.

I've looked in their code but I don't quite understand it. I don't want to just copy and paste without knowing what exactly happens.


Solution

  • It's simpler then you think, they just use hash. You can look at examples on colorbox site with events. Get href like this: How do you get a return value from a colorbox?, then set hash: document.location.hash and on close event remove hash.