Is it possible to change the value of a parameter in a querystring in javascript?

1

For example I have this querystring www.meusite.com.br?parametro=1 . I would like to change value 1 to another value when a certain function is called, without having to load the page again (if possible).

    
asked by anonymous 18.09.2015 / 22:11

1 answer

2

To change the URL via javascript would look like this:

var Url = window.location.host;
document.location = Url + "?parametro=2"; //muda o valor de "parametro" para 2

However, it is not possible to change the URL without reloading the page, this is a security restriction.

Imagine that the user receives a fake email as if it were from a bank, clicks a button and is sent to a fake page but soon after that the URL is changed to the bank's true address. The user fills in the login data and via ajax is recorded in a database and then redirects it to true page. It would be a serious security flaw!

Although there are other ways to detect if the URL is false, most users do not know how to do it.

    
21.09.2015 / 12:01