使用javascript重定向到html页面 [英] redirect to html page using javascript
问题描述
1-我可以刷新页面而不调用onload方法吗?如果是的话?
或
2-我可以重定向到页面中的特定方法,以避免每次都调用onload方法吗?如果是的话
或
3- can我在onload方法中编写任何东西,让我只在第一次调用方法?如果是的话
注意:我知道在Web应用程序中每次必须调用load函数页面重新加载,但是我有什么解决方案可以解决这个问题吗?
两个选项:
- 您可以使用cookies。登录时设置cookie并在加载期间检查它。然后在执行初始化后清除它,以便下次加载检查失败。
- 您可以使用该地址,作为参数,如
?justLoggedIn
,或#justLoggedIn
之后的哈希值。然后检查并重定向到相同的网址减去justLoggedIn
部分。#
版本的优点是它实际上不会重新加载页面,这与使用?
版本时不同。
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?
Two options:
- 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.
- 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 thejustLoggedIn
part. The advantage of the#
version is that it doesn't actually reload the page, unlike when using the?
version.
这篇关于使用javascript重定向到html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!