Skip to Content

Handle Hashtag change

I want to handle a hashtag change in my SAPUI5 app. For examples sake, let's say I want to throw a popup with the value of the hashtag, what's the correct way to do it?


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jun 15, 2014 at 11:53 PM

    Hi Joao,

    I think you can use the sap.ui.core.routing.HashChanger to attach an "hashChanged" event handler.

    var oHashChanger = HashChanger.getInstance();
    oHashChanger.attachEvent("hashChanged", function(oEvent) {
      alert(oEvent.getParameter("newHash") + "," + oEvent.getParameter("oldHash"));



    Add comment
    10|10000 characters needed characters exceeded

      1. var oHashChanger = HashChanger.getInstance();
      2. oHashChanger.init();
      3. oHashChanger.attachEvent("hashChanged", function(oEvent) {
      4. alert(oEvent.getParameter("newHash") + "," + oEvent.getParameter("oldHash"));
      5. });

      I needed to add step 2. Now it works.