1

i need help in function location.reload()

My code:

$('.class').on('click', function(){
location.reload();
alert("yea");
});

Problem is big, because webrowser first show alert "yea" and next to reload page.. I need call function when location end reload.

Someone can help me?

1
  • You want after reload show "yea"? Commented Jan 20, 2015 at 12:12

1 Answer 1

1

Try this by using localstorage or cookies like,

$('.class').on('click', function(){
   localStorage.setItem('reload',1); // set the reload key for alert
   location.reload();
});
if(localStorage.getItem('reload') && localStorage.getItem('reload')==1){ // if you get the key and ==`1
   localStorage.removeItem('reload'); // remove the key, to prevent next alert
   alert("yea"); // alert first time
}

Also read storages

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.