The oldURL read-only property of the HashChangeEvent interface returns the previous URL from which the window was navigated.

Value

A string.

Examples

js
window.addEventListener("hashchange", (event) => {
  console.log(`Hash changed from ${event.oldURL}`);
});

Specifications

Specification
Product help
  • Constructor
    1. Event
  • Related pages for HTML DOM
    1. HTMLAnchorElement
    2. HTMLBaseElement
    3. HTMLDListElement
    4. HTMLDivElement
    5. HTMLFieldSetElement
    6. HTMLHRElement
    7. HTMLIFrameElement
    8. HTMLLabelElement
    9. HTMLMediaElement
    10. HTMLModElement
    11. HTMLOptionElement
    12. HTMLPictureElement
    13. HTMLScriptElement
    14. HTMLStyleElement
    15. HTMLTableElement
    16. HTMLTextAreaElement
    17. HTMLUListElement
    18. ImageData
    19. MessagePort
    20. PageTransitionEvent
    21. RadioNodeList
    22. WorkletGlobalScope
  • ","source":{"folder":"en-us/web/api/hashchangeevent/oldurl","github_url":"https://github.com/mdn/content/blob/main/files/en-us/web/api/hashchangeevent/oldurl/index.md","last_commit_url":"https://github.com/mdn/content/commit/b6984118ac9482e683a654edfefa4b426ca3c7ca","filename":"index.md"},"summary":"The oldURL read-only property of the\nHashChangeEvent interface returns the previous URL from which the window\nwas navigated.","title":"HashChangeEvent: oldURL property","toc":[{"text":"Value","id":"value"},{"text":"Examples","id":"examples"},{"text":"Specifications","id":"specifications"},{"text":"Browser compatibility","id":"browser_compatibility"}],"baseline":{"baseline":"high","baseline_low_date":"2015-07-29","baseline_high_date":"2018-01-29","support":{"chrome":"16","chrome_android":"18","edge":"12","firefox":"11","firefox_android":"14","safari":"6","safari_ios":"6"}},"browserCompat":["api.HashChangeEvent.oldURL"],"pageType":"web-api-instance-property"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant