3

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?

3
  • You're referring to methods in a page. Is this ASP.NET? Commented Jun 15, 2012 at 13:20
  • i assume you dont use servlet right !? Commented Jun 15, 2012 at 13:20
  • no it is not ASP.NET, i don't use servlet right Commented Jun 16, 2012 at 5:48

2 Answers 2

2

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.
Sign up to request clarification or add additional context in comments.

2 Comments

i use cookies and this is the reference site blogs.x2line.com/al/articles/316.aspx thanks Supr
you have to be careful though in using cookie option as security perspective the cookie could be deleted by browser tools such as firebug am i right?!
2

You could refresh the page by redirecting to

[urlOfCurrentPage] + "?redirected=true"

and then in the onLoad method check if there is a GET "redirected" parameter in the URL, and if so, skip the onload.

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.