pstein Posted October 9, 2022 Share Posted October 9, 2022 (edited) As you know more and more website introduce a page referrer to know from which other page the visitor came from. Therefore the first page append something like "?utm_source=sfmc&utm_medium=email&utm_campaign=OEM......" to the target URL: e.g. http://www.foobar.com/some/path/myproduct/desc.html?utm_source=sfmc&utm_medium=email&utm_campaign=OEM Assume I derive from within a javascript the current url similar to var address = document.URL; How can I strip off everything after the .html beginning with "?" (mostly ?utm_source.....) . Edited October 9, 2022 by pstein Link to comment Share on other sites More sharing options...
Ingolme Posted October 10, 2022 Share Posted October 10, 2022 This is one way to do it. if(location.search) { location.href = location.pathname; } It causes a page reload, though. The history API lets you change the URL without reloading, but I've seen it misused a lot, causing websites to not function as expected. https://developer.mozilla.org/en-US/docs/Web/API/History/pushState 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now