-2
     function theLast(){

             if (document.getElementById('dont').checked) {
             document.getElementById('dont').checked=false;}
             else if(document.getElementById('know').checked){
                 document.getElementById('know').checked=false;}
             else if(document.getElementById('master').checked){

                 document.getElementById('master').checked=false;}
                 else {
                 document.getElementById('ans').reset();}
      document.getElementById("pop2").style.display = 'none';
       document.getElementById("myPopup").style.display = 'none';
       document.getElementById("pop3").style.display = 'none';


        document.getElementById("pop4").style.display = 'block';
         document.getElementById('pop4').style.position = "absolute";
         document.getElementById('pop4').style.top = '250px';
        document.getElementById('pop4').style.left = '250px';
        setTimeout(function(){
        document.getElementById('pop4').className = 'waa';

   }, 2500);



window.location.reload();


 }

i want to reload my page at the end of this function tried window.location.reload() location.reload(true)

is there any other way i can reload my page?

Rahul
  • 15
  • 1
  • 1
  • 5
  • Possible duplicate of [How to reload a page using Javascript?](http://stackoverflow.com/questions/3715047/how-to-reload-a-page-using-javascript) – showdev Sep 20 '16 at 16:55
  • 3
    1. Clean up your code. 2. I can’t spot `window.reload` nor `window.location.reload` (which would be correct) anywhere in your code. – idmean Sep 20 '16 at 16:56
  • I don't see anywhere in the code where you're calling `window.location.reload`. That might be why its not working. –  Sep 20 '16 at 16:59
  • 1
    "reloads the resource from the current URL". See [`location.reload()`](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload). – showdev Sep 20 '16 at 17:10
  • see the edited code, even that is not working. i am running on local host – Rahul Sep 20 '16 at 17:32
  • If you're going to edit your question, please reformat it. Are you sure you are calling `theLast()`? By the way if you're going to reload the page anyway, why are you doing all the stuff above the call to `reload`? –  Sep 20 '16 at 17:37
  • yeah. im calling the function theLast() . I did all those because i could'nt refresh the page – Rahul Sep 20 '16 at 17:51
  • Take a look at this answer: http://stackoverflow.com/a/3715123/3206247 and the comment of this answer here: http://stackoverflow.com/a/3715071/3206247 – Marco Sep 20 '16 at 17:56
  • 1
    Fire up your debugger, and place a breakpoint on the `window.location.reload` line. Make sure it reaches there. Then step over the line. Your browser will reload. Most likely, you will find that control never reaches that line, because of some other error in your logic. –  Sep 20 '16 at 18:53
  • You didn't provided your browser versions, but I've made this fiddle and it is fully functional https://jsfiddle.net/dj7c7q0o/ – Marco Sep 20 '16 at 19:21

2 Answers2

2

I'm not sure about the support for location.reload but why don't you try this:

window.location.href = window.location.href;

Marco
  • 1,279
  • 1
  • 15
  • 26
0
$('#something').click(function() {
location.reload();
});

Add this In Your Script

Samudrala Ramu
  • 2,088
  • 1
  • 15
  • 36