Javascript – Removing querystrings from the URL before page refresh

cachingcookiesjavascriptjqueryurl-rewriting

After a new user signs up, I need to redirect the user to the home page and display a twitter-style welcome message. I initially tried using the jquery cookie plugin to store my message and display it on the redirected page if the cookie is present, but the problem was that it didn't work across all browsers. Firfox on Safari does not delete the cookie, so the message keeps showing everytime the browser is refreshed. Here's the code:

if ($.cookie("message")) {
    TwentyQuestions.Common.ShowMessageBar($.cookie("message"), 7000);
    $.cookie('message', "any_value", { expires: -10 })
}

So I decided to use querystring instead, but now the problem is similar. When the home page load, the query string is detected and the message is displayed. But how do I remove the querystring from the URL so that the message doesn't show everytime the page is refreshed?

Thanks!

Best Solution

Could you do:

window.location.href = window.location.href.split('?')[0];

It works, but I'm not for sure if this is what you are looking for?