Redirect back after login -


i need force login visit web site, reason when visitor shows page redirect him login page , if logins or registers web site redirect him time original page visited. problem in last step, i'm not able redirect original page because url not saved in history before first redirect

for first redirect use not users

<script type="text/javascript"> window.location.href = '/login-guest'; </script>  

for second redirect, after login or registration use

<script type="text/javascript"> history.back(-1); </script> 

i think need add script add url history before first redirect

tx, best regards

you try using html5 sessionstorage store users webpage in first script , retrieve in second script

edit: code:

edit 2: onpageload

because of onload() cannot move checkpage function body

page 1:

 <!doctype html>  <html>  <head>  <script>  function checkpage(){     if(sessionstorage.visited != 1){         sessionstorage.startingpage = document.url;         window.location.href = 'sessionstorage2.html';     }     else{         return;     }  }  </script>  </head>  <body onload='checkpage()'>  text or   <br><br>   <script>  function reset(){     sessionstorage.visited = 0;  }  </script>  <button onclick='reset()'>reset function</button>  </body>  </html> 

page 2:

<!doctype html> <html> <body> <script> function return(){     window.location.href = sessionstorage.startingpage;     sessionstorage.visited = 1; } </script> <p><button onclick="return()" type="button">return page 1</button></p> </body> </html> 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -