Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8785727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:26:24+00:00 2026-06-13T21:26:24+00:00

I am trying to fire an JSF backing bean function from JavaScript when the

  • 0

I am trying to fire an JSF backing bean function from JavaScript when the page is being unload. It is working fine in IE and chrome but not in Firefox.

This is how the onunload event get trigger in XHTML:

<h:body onunload="onPageUnload()">
  <h:form id="theForm">
    <p id="hiddenButton" style="display:none">
      <h:commandLink id="hiddenCloseEvent" styleClass="button" action="#{theBean.doHiddenCloseEvent}">
        <f:param name="action" value="CLOSE"/>
      </h:commandLink>
    </p>
  ...
  </form>
</h:body>

When the unload event is receive, the follow JavaScript will be execute. There are 2 versions, one is for IE, and the other one is for Google Chrome.

IE version:

function onPageUnload() {
  if( detailPage == "false" ) {
    document.getElementById('theForm:hiddenCloseEvent').click();
  }
}

Google Chrome version:

window.onbeforeunload = function(e) {
  onPageUnload();
};

When the onPageUnload() is execute, it trigger the hidden input button JSF component click event, and then fire the JSF backing bean, theBean, function theBean.doHiddenCloseEvent to do some processing. Now the situation is the JSF function is get executed in IE and Google Chrome version but not being trigger in Firefox, may I know how this problem could be solve?

UPDATE

I have modified the code like below:

function onPageUnload() {
  if( detailPage == "false" ) {
    alert('before');
    document.getElementById('theForm:hiddenCloseEvent').click();
    alert('after');
  }
}

From the code above I found out that the before get prompt but the after doesn’t prompt. This test case is verify whether the component isn’t visible in the web browser.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:26:25+00:00Added an answer on June 13, 2026 at 9:26 pm

    I believe this is a special issue with firefox. It’s recommended you use onbeforeunload to cater for FF.

    See the Firefox forum and also here. onbeforeunload is not supported by all browsers though

    You could use both events to cover both bases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fire an event from a unmanaged function using a pointer
I'm trying to fire a function when the keyup event happens. This works fine
I'm trying to fire on my Slide toggle but is not working as is
I'm trying to fire a 404 from a list. Something like this: function (head,
I'm trying to fire off several HTTP requests from an ASP.NET page. The page
I am trying to fire a javascript by onclick event of submit button but
I'm trying to fire an event from an external HTML page opened inside of
I'm trying to fire a click event on my select options. This is working
I am new to jQuery and am trying to fire a function on a
I am working on a WPF project, and I am trying to fire an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.