0

I'm attempting to remove a url parameter status from the url but in the following alert, the parameter is still there.

var addressurl = location.href.replace(separator + "status=([^&]$|[^&]*)/i", "");
        alert(addressurl);
            location.href= addressurl;

How do i solve?

3 Answers 3

2

You are confusing regex with strings.

It should be:

var addressurl = location.href.replace(separator, '').replace(/status=([^&]$|[^&]*)/i", "");
Sign up to request clarification or add additional context in comments.

Comments

1

Javascript context in web pages are to the page you are working on.

When you reload, redirect or move to any other page, javascript changes done in previous page will not be there. This has to be handled from server side.

1 Comment

what should happen is a the page should go to the new url without the parameter status nothing should be handles server side.
0

Refresh repeats the last request to the server, which is going to ignore your javascript changes. Instead navigate to the new url with window.location = addressurl;

4 Comments

tried this, the same url is alerted. the parameter status is still there.
If your alert is showing the status parameter, the issue is with your replace, not with the navigation.
what is wrong with my replace? is the regex wrong?
I don't know, I'll look. Your original question was about why it disappeared on refresh, which is a different problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.