Sharepoint offers the following JavaScript function to get a QueryString parameter value:

GetUrlKeyValue('a', false, 'www.example.com?a=test')

I would like to know if there is a similar JavaScript function to get a parameter value from within inplview.js API hashed url like the following:


From the previous URL, I would like to extract 'FilterField1' and 'FilterValue1' values ('Foo' and 'Bar' respectively), as if those were regular QueryString parameters.

  • JavaScript does not offer any function to get query string parameters. But you can create your custom function to get query string parameters. Mar 31, 2018 at 17:09

2 Answers 2


I didn't find a built in function to achieveing this. So I wrote a very simple function to get what I need.

I post this as an answer but I'm still open to suggestions.

Thank you.

function GetUrlHashKeyValue(key) {
    var value = '',
        hash = window.location.hash,
        fv1Index = hash.indexOf(key + '%3D');

    if (fv1Index != -1) {

        value = hash.substr(fv1Index + key.length + 3);

        // value could end at the end of the string, or when another value comes right after
        // One dash "-" found means another parameter follows, only if it is not followed by another dash "--"
        // Double dash "--" is one dash escaped within a string.
        value = value.replace(/--/g, '||');

        // Now, if we find a single dash "-", it is delimiting a new parameter
        var dashFoundAt = value.indexOf('-');
        if (dashFoundAt != -1) {
            value = value.substring(0, dashFoundAt);

        // Rollback our custom double dash escaping
        value = value.replace(/\|\|/g, '--');

    return value;

var filterVal = GetUrlHashKeyValue('FilterValue1');

You might need to decode the result:


See the second answer here: https://stackoverflow.com/questions/3552944/how-to-get-the-anchor-from-the-url-using-jquery

Or do a search for "javascript read anchor".

  • Thank you. I know I can get the entire anchor from the URL, I just wanted to know if there is any built in function for parsing querystring-like parameters built in the anchor parameter when using inplview.js in Sharepoint.
    – zed
    Apr 3, 2018 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.