Hash part in URL

Hello I have been working with the WixRouterRequest in ‘wix-router’ module to get some parameters in the URL before redirecting. I noticed that the content after “#” in url is parsed into “hash” but I did not see any function that allows me to get this.

I tried to get the whole URL which expected to include the hash part but the returned value omitted the hash part. Any advice in getting the hash part? Thank you in advance.

Hey
Have you tried the below. The docs says you should also get the hash at the end. Then just use string tools to get the parts after the hash.

import wixLocation from 'wix-location';

// ...

let url = wixLocation.url;
// Premium site: "https://domain.com/animals/mammals/elephant?species=african-elephant#desc"
// Free site: "https://user.wix-sites.com/zoo/animals/mammals/elephant?species=african-elephant#desc"

Sorry for the late reply.
Yes I have also tried this out but still the hash part is omitted in the console log.
My site is a premium site. I am not quite sure why it is different from the document.
My code are as follow:


import wixLocation from 'wix-location';
$w.onReady(function () {
 let query = wixLocation.url;
    console.log(query);
});

@evayautszyan Did you ever get an answer to this? I’m having the same problem.

Hi!
You can try using hash from wix-location:

import wixLocation from 'wix-location';

//...

let urlFragment = wixLocation.hash; 

Hope this helps!

EDIT: it isn’t listed on the Wix Corvid API Reference, but on the old Wix Code API Reference: http://intense-brook-61045.herokuapp.com/wix-location.html#hash

Facing same issue sometimes even wixLocation.hash doesn’t give the hash value even if it is present in URL

This is an old post and should be closed.
Please create a new post with your problem.