Disable the browser back-button in Prime Faces 7 / Sapphire application

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
alexanderdm
Posts: 40
Joined: 02 Mar 2014, 12:26

26 Apr 2023, 06:00

Dear Sirs!

I need to disable the browser back-button in my Prime Faces 7 / Sapphire application run under Wildfly 17. I tried all options (including comments) from the question below, but nothing happened:

https://stackoverflow.com/questions/759 ... pplication


Could you please help me?

Thank you and kind regards,
Alex

olgubasak
Posts: 98
Joined: 05 Jan 2023, 11:05

26 Apr 2023, 08:44

Hi,

Could you please update your PrimeFaces and template version and try again?

Best regards,

alexanderdm
Posts: 40
Joined: 02 Mar 2014, 12:26

21 Jun 2023, 07:58

Dear Mr. olgubasak!

I have updated my Primefaces to Version 12 and my Sapphire Template to Version 5.1, but the problem still persists.
What would you advise me?

Thank you and kind regards,
Alexander

olgubasak
Posts: 98
Joined: 05 Jan 2023, 11:05

22 Jun 2023, 11:52

Hi,
When I did research on your request, I found two separate code examples that you can use. Can you try the ones I sent?

This code moves the page forward in response to the browser's back button being clicked, which effectively disables the back button.

Code: Select all

history.pushState(null, null, location.href);
window.onpopstate = function () {
    history.go(1);
};

Another code:

This JavaScript code disables the browser's back button as soon as the page loads.

Code: Select all

window.onload = function() {
    if (typeof history.pushState === "function") {
        history.pushState("disabled", null, null);
        window.onpopstate = function() {
            history.pushState("disabled", null, null);
        };
    }
};
I hope one of these codes solves your problem.
Best Regards,

Post Reply

Return to “Sapphire - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests