简体   繁体   中英

Remove hash from URL (lightbox)

I know there's a lot of questions about my problem, but I can't find any solution.

I have a lightbox, every pictures has got a specific ID with hash (#picture-1, #picture-2, ...)

I want to remove hash from URL :

gallery.php/#picture

to

gallery.php/picture

Script :

$(location).attr("hash","value"));

I find something to remove the hash but it broke my lightbox (redirect to 404 error)

$(location).attr("href","value"));

Any idea ? Thanks.

you need a javascript or php routing, javascript frameworks as angularjs has a route module (codeigniter for php has one too). You need to prevent location href behavior.

When you change the location gallery.php/#picture (hash changing event fired) but gallery.php/picture tries to redirect picture directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM