Closing Limelight lightbox that was opened via a link

I’m using the “?ll=lightboxID” syntax appended to a URL to open a Limelight lightbox from a link, which works great. But when the lightbox is closed, ?ll=lightboxID remains appended to the URL, and if the user reloads the page, the lightbox opens again.

So I’ve been trying to come up with a script that uses [infix:userClose(e,instance)] to trigger a reset of the page address to the base URL, without the ?ll=lightboxID appended.

But I’m a total noob when it comes to js, and after 3 days of trying, still haven’t been able to crack it.

Can someone point me on the right track?

Yes, its a bit tricky if you don’t want to force a reload of the page when you alter the query string in the URL but here’s how.

If you just trigger the code when the user closes the initial lightbox then it means that you don’t need any unreliable delays or hacks to know when to re-write the url.

Put this into the site wide javascript code (if you want to to work on all pages)

var newurl = window.location.href.split("?")[0];

Thanks very much, Tav. Never would have got there on my own. Especially nice that it doesn’t force a page reload.

I’m using it on a two-page website that displays English or Japanese content depending on the browser language setting (or, once the user has entered the site, on the language they select). So I put the script in the body of each page to target the relevant lightbox. Works a treat!

P.S. In an attempt to make my gratitude more tangible, I just tried to make a donation to BWD, but got the message: ‘Donations to this recipient cannot be made from your country’, which is something I’ve not seen before. Anyway, I tried, and thank you again for your help!