0

When I used document.location.reload() as in case1 below, it doesn't work. But when I add an alert() as in case2, it works. I want to figure out what happened?

//case1: does not work document.location='rc_msg.php?remove=0'; document.location.reload(); //case2: work document.location='rc_msg.php?remove=0'; document.location.reload(); alert("OK!!"); 

I did not notice I entered '=' twice, I am sorry about that. I had tried the opinion solution below, but they did not work neither

2
  • 1
    document.location is an object, you're trying to compare it to a string... Commented Dec 13, 2013 at 4:00
  • Your code makes no sense...What are you trying to do exactly? SHow your real code. Commented Dec 13, 2013 at 4:42

2 Answers 2

1

Do you want to test the location (double equals) or assign it the new location (single equals)?

Try:

document.location='rc_msg.php?remove=0'; document.location.reload(); 
Sign up to request clarification or add additional context in comments.

1 Comment

And what you typed makes no sense...How can you set the location and reload? ;)
1

document.location returns a string, now deprecated and replaced by document.URI.

window.location (or location) is an object with a reload method.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.