Refresh Page On Button Click And After That Call An Function
I am trying to refresh an web page on button click and after page refresh call an function. But its reverse is not happening i.e. first call the function and after that refresh the
Solution 1:
use below code
<body onload="onrefresh();">
<a href="javascript:myfun();">
functionmyfun(){
window.location.search += '&reload=true';
}
functiononrefresh(){
if(gup("reload")=='true'){
// DO whatever want to do.
}
}
functiongup( name ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return"";
elsereturn results[1];
}
Solution 2:
<ahref="javascript:abc();"><script>functionrestartall() {
$('#text').append('hello');
}
functionabc() {
document.location.reload();
restartall();
}</script>
Solution 3:
When you reload page you're loosing JavaScript call stack. You would have to append some parameter to URL or use cookie.
Post a Comment for "Refresh Page On Button Click And After That Call An Function"