im trying to make a reset button that refreshes the page. here is my code :

function refresh() {

window.location.reload(true)

}

and in my html I put this:

<input type="button" onclick="refresh()">

can somebody help me?

3 answers

danwellman 5600
1
point

Try taking the true parameter away, the reload function does not require any arguments

Answered over 8 years ago by danwellman
  • adding an argument shouldn't be the issue, but its a good thing to note and do anyway Ktash over 8 years ago
Ktash 1851
0
points

The issue doesn't seem to lie in the code you've listed here. Maybe give us a bit more of the code surrounding the above (without copy-pasting the whole thing), or investigate any javascript errors on the page, as those can stop any other javascript from being run sometimes. If you haven't already, use Firebug to pause the javascript and walk through it step by step and make sure it is even getting to the function. You can also put an alert in the function to see if it gets there.

Answered over 8 years ago by Ktash
  • It may be placement of the code (as it is with question the OP's earlier question: http://doctype.com/changing-font-javascript), but I wanted to see if removing the argument fixed as this code is event driven, whereas the other code isn't... danwellman over 8 years ago
  • It definitely makes sense. Javascript should just throw out the argument though, so it shouldn't be an issue in theory. My thought is that maybe the function isn't getting defined because of another error in the javascript. Ktash over 8 years ago
  • Always a possibility, a response from the OP with further debugging info would be pretty awesome at this point ;) danwellman over 8 years ago
0
points

Try using:

<a href="javascript:location.reload(true)">Refresh page</a>

OR

<input type="button" value="Refresh page" onclick="location.reload(true)">
Answered over 8 years ago by Jared Tomeck