Monday, January 22, 2007

Hack #2: When Is A Location Not A Location?

Problem: When asking a browser window to reload, the POST object goes along with. This isn't user friendly (gives an annoying alert) and potentially bad by submitting data twice that should be sent once.

Solution: Instead of reload(), use "window.location.href = window.location.href". Yes, it looks idiotic but since the href is merely a string, this tells the location object to set to itself - but without the offending POST info.

No comments: