Function getScriptQueryParam

  • Retrieve a query parameter from a script URL in the browser.

    Usage:

    const ret = getScriptQueryParam('test', 'https://example.com/example.js');
    console.log(ret);

    Output:

    hello
    

    Parameters

    • param: string

      The name of the query parameter to retrieve.

    • matchString: string = ""

      An optional substring to match in the script URL. If not provided, defaults to matching the ".js" substring.

    Returns string

    The decoded value of the specified query parameter, or an empty string if no matching parameter is found.