Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to stay at the current page without reloading?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01192067
Message ID:
01192135
Views:
12
Using a physical URL in the location.href will always reload the page. If you want to jump into another part of the page you need to use the hash anchors on their own:

location.href="#bookmark";

This should not reload the page.

If you have an anchor in the page you can also do:

document.getElementById("YourAnchor").focus();

assuming the anchor has an ID.

+++ Rick ---

>Hi all,
>
>I have a javascript running whenver the form's onunload event fires. The javascript will popup a confirm box to ask user whether to stay at the current page or redirect to somewhere else.
>
>Howoever, when I use " window.location.href = window.location.href ", the page will be reloaded, which some changed values on the form will be missing. Therefore, I added a hash, window.location.href = window.location.href + "#", but it's not working. I have tested with " __doPostBack('__Page', '') ", but somehow it's not working in some forms. Is there a way to stay at the page without reloding the page? Thanks.
>
>Here is my javascript:
>
>
>function onPageUnload()
>{
>     var result = confirm("Do you want to leave the page?")
>     if (result)
>         window.location.href = window.location.href
>     else
>         windwo.location.href = "./Logout.aspx"
>}
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform