質問

I'm using ASP.Net/VB. The problem is that I have some floating DIVs that make you want to hit back in your browser to close the floating DIV instead of clicking close.

My idea is that when you click a button on the page to open a form in a floating DIV, it adds a browser history entry for "#" if the most recent history isn't already "#". When you close the form on the floating DIV, delete the browser history for "#" that we added. If the user accidentally hits back while the form is displayed, they should remain on the page because it should try to go to "#". The form itself would disappear, and if the user hit back in the browser again, it would just work just fine.

If you know this is possible, let me know and I can figure out how to do it myself, I just don't want to spend too much time attempting to do something that's not possible.

役に立ちましたか?

解決

I would consider looking into the History API and more specifically, pushState() within javascript. I've been using it and it's so much better plus search engines like it.

history.pushState(null, null, '/page.aspx?showform')

This allows you to change the URL without a refresh and you can do away with the hashes. Back/forward works fine.

This page sums it up nicely: http://diveintohtml5.info/history.html

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top