How to get a query string value in JS?

Learn how to get a query string value in JavaScript without jQuery
14 August 2017   2483

You can solve this issue even without jQuery. Here's the code:

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

Usage:

// query string: ?foo=lorem&bar=&baz
var foo = getParameterByName('foo'); // "lorem"
var bar = getParameterByName('bar'); // "" (present with empty value)
var baz = getParameterByName('baz'); // "" (present with no value)
var qux = getParameterByName('qux'); // null (absent)

Please note: If a parameter is present several times (?foo=lorem&foo=ipsum), you will get the first value (lorem).

Critical Zero-Day Exploit to be Found at Firefox

Using this bug scammers could install programs, view, change or delete data, as well as create new accounts; users are recommended to update ASAP
19 June 2019   865

Coinbase Security and Google security researcher Samuel Gross discovered a vulnerability in Mozilla Firefox browser that could manipulate Javascript objects. It has already been used to attack users of cryptocurrency. This is reported on Medium.

The zero-day vulnerability received a CVE-2019-11707 identifier, and the bug was assigned a critical or highest threat level by the Firefox,

Critical Impact — Vulnerability can be used to run attacker code and install software, requiring no user interaction beyond normal browsing.
 

Firefox Vulnerabilities Types Description

In fact, the attackers could force users to visit malicious websites and thus be able to execute arbitrary code on the devices of their victims. The scammers who used the bug could install programs, view, change or delete data, as well as create new accounts.

Users are urged to upgrade as soon as possible to the new version of Firefox 67.0.3 and Firefox ESR 60.7.1, in which the vulnerability is fixed.