Change DOM URL without updating in address bar

Viewed 51

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 .

1 Answers

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

Related