Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redirect to html page using javascript

i have 2 html page the first one is the login page and the second, when i login i redirect to the main page, there is a must must execute on load, only at the first load of the page after login this method must call. when i reload or refresh this method is call again.

1- can i refresh the page without calling the onload method? if yes how?

or

2- can i redirect to a specific method in the page to avoid calling the onload method every time? if yes how

or

3- can i write any thing in the onload method that keep me calling the method only at the first time? if yes how

Note: i know that in web application it is must call load function at each time the page reload, but is there any solution that i must do to solve this problem?

like image 771
Georgian Citizen Avatar asked Mar 26 '26 04:03

Georgian Citizen


1 Answers

Two options:

  1. You can use cookies. Set a cookie when logging in and check for that during load. Then clear it after performing your initialization so that next load the check will fail.
  2. You can use the address, either as a parameter like ?justLoggedIn, or a value in the hash after #justLoggedIn. Then check for that and redirect to the same url minus the justLoggedIn part. The advantage of the # version is that it doesn't actually reload the page, unlike when using the ? version.
like image 86
Supr Avatar answered Mar 27 '26 18:03

Supr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!