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.

2
  • Do you want to redirect to another page or reload the same page? (Both in terms of content and URL) Commented Feb 5, 2017 at 7:49
  • Could you pl. make it more clear? What you want else than this jsfiddle.net/7rujg076/2 Commented Feb 5, 2017 at 7:52

1 Answer 1

4

To reload a page using javascript, use:

window.location.reload();

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

Sign up to request clarification or add additional context in comments.

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.