Closed Bug 400122 Opened 18 years ago Closed 18 years ago

Firefox should generate an event when the value of window.location.hash changes

Categories

(Core :: DOM: Events, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 385434

People

(Reporter: billhigg, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7 Build Identifier: Many Ajax applications use the value of the location's fragment (or hash) value to denote application state. E.g. myAjaxyBugzilla.html#viewBug&id=395652 myAjaxyBugzilla.html#search&q=Crash In this pattern, the value of the fragment does NOT correspond to a named anchor in the page (as it would with a 'normal' web page). Rather the Ajax application monitors changes to the fragment (using setInterval and a cached value of the current fragment) and calls corresponding JavaScript code when the fragment changes (naturally if any other part of the location changed, the page would unload). You have to poll changes to the fragment because there are multiple ways that it can change: 1) User performs some page action that changes the fragment's value (e.g. clicks a hyperlink, clicks a button, etc.) 2) User uses a browser control like back, forward, history 3) User manually edits the location It's pretty inefficient to poll the location, and I think this pattern is common enough that it would help Ajax developers if Firefox fired an event when the fragment changes (for any of the above reasons). This way, the Ajax application only does work when the fragment actually changes rather than 5 times a second in a setInterval 'loop'. I suggest window.onFragmentChange. PS - See the URI associated with Bug 395652 to see this pattern in action. Reproducible: Always
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.