I have problem when i try to add new params in existing url with location.hash
. After adding new two params hash sign is automaticly added to url #
I have link: http://work.example.rs/index.php/profile/photos
on click i open new modal window where i load full size image and add new param to url like photo_id
and photo_guid
preview: function() {
$('body').on('click', '#open-picture-modal', function (e) {
e.preventDefault();
var $this = $(this);
var guid = $this.data('guid');
var photo_id = $this.data('id');
var url = baseurl + '/picture/preview/?pgid='+guid+'&pid='+photo_id;
location.hash = "&pgid="+guid+"&pid="+photo_id; // <-- Here is line
});
},
After open modal url is changed like this: http://work.example.rs/index.php/profile/photos#&pgid=E10B6F66-9686-9E29-55BA-3C197004F608&pid=6
In this url u can see #
in url is added i dont know whay?
Html:
<?php $image_path = upload_userdata_url() .'/'. $photo->owner_id .'/'.'photos/'.$photo->photo_guid .'/'. $photo->photo_name;?>
<a href="<?= $image_path;?>" class="thumbnail" data-guid="<?= $photo->photo_guid; ?>" data-id="<?= $photo->photo_id; ?>" id="open-picture-modal" data-gallery>
<div class="uiMediaThumbImg" style="background-image: url(<?=$image_path;?>);"></div>
</a>
You are using hash
which append the #
symbol to url. You can user History API provided by HTML5
replace your line
location.hash = "&pgid="+guid+"&pid="+photo_id;
to
window.history.pushState('', '', "&pgid="+guid+"&pid="+photo_id);