0

I currently have a Javascript reset function that looks like this :

function reset(){
        document.body.innerHTML = login;
}

and the login variable looks like this:

var login = '<div id="error-container" ></div><div style="text-align:center"><ul style="list-style-type: none;" ><li><input id="name" type="text" name="name" value="" placeholder="Enter your Name!" ></li><li><input id="age" type="text" name="age" value="" placeholder="Enter your Age!" ></li><li><input id="gender" type="text" name="gender" value="" placeholder="Enter your Gender!" ></li></ul><button type="button" name="button" onclick="setUser()">Start chating!</button></div>

the variable is basically an HTML page, so I'm wondering if there's a way of just reloading the HTML page using this Javascript function instead of just writing all the HTML code out for a variable and displaying it.

Martin Guo
  • 25
  • 1
  • 1
  • 4

1 Answers1

4

To reload a page using javascript, use:

window.location.reload();

https://developer.mozilla.org/en-US/docs/Web/API/Location/reload

spazhead
  • 304
  • 3
  • 14