Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change DOM URL without updating in address bar

I am using third party analytics script in my ASP.Net MVC site. The script logs the current URL from the "document.location.href". I want add some additional encrypted data in the URL that is passed to the third party site. But i don't want to change the URL in the address bar has the user will also see the updated URL.

Eg:

Url in Address bar = "example.com/page1"

URl in document.location should be = "example.com/page1/{encryptedstring}"

So, when the third party script get the current URL the updated URL will be logged.

Note: I can edit the third party script to update the URL based on my needs. But i don't want to update it since it may cause some licensing problem .

like image 544
hari prasath Avatar asked Nov 07 '22 00:11

hari prasath


1 Answers

document.location is read-only. So unfortunately you cannot set it directly or expect it to differ from the address bar url.

like image 50
Matthi Avatar answered Nov 13 '22 04:11

Matthi