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

  • SEARCH
  • Home
  • 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 8295227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:30:49+00:00 2026-06-08T14:30:49+00:00

I am trying to trigger an event in JavaScript using a Java class. How

  • 0

I am trying to trigger an event in JavaScript using a Java class.

How can I send javascript code (either direct input or from a file) in a Java class to a specified destination file which is already opened in the browser (Firefox)?

Currently I’m using the ScriptEngineManager to run my JavaScript code, but the code is executed in my Java environment and I don’t know how to trigger an event in this way (as I cannot use e.g. window.postMessage(“hi”, “*”);)

Any suggestions how to solve this? Work-arounds are also appreciated (preferably without extensions, plugins, …).

Best regards.

  • 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-08T14:30:50+00:00Added an answer on June 8, 2026 at 2:30 pm

    When executing from java you have no access to window events – because there is no browser.

    I don’t really understand the use case here but you could load the destination file into an iframe and then do a meta refresh – once you update the files contents then the updated results will be displayed on the next refesh.

    In any case you can only return results from the inputted javascript functions back to java – not call events.

    You could pass a javascript function (a call that simulates the event) back to the browser and then execute it.

    How you would pass this back to the client depends on the situation :

    • It could be on the response of the request to upload the javascript
    • You could use the meta-refresh mechanism
    • You could look into an ajax style way with client polling (if you didn’t want to refresh manually each time).

    EDIT

    The server has no link to the browser between requests. To asynchronously receive a server event in a browser you could have a look at:

    • WebSockets
    • Comet

    So the browser would receive notification when the task is complete and then it would be able to react – for instance prompt for the tab to close.

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

Sidebar

Related Questions

I am trying to trigger the onScroll event this way using prototype: Event.observe(document, 'scroll',
I'm trying to trigger a javascript onMouseOver event without having the onMouseOver attribute on
I'm trying to check a checkbox using jQuery and trigger the onclick event in
I have a CheckListBox in c# and I am trying to trigger an event
I'm trying to add some JavaScript functions to a page with SSRS. I'm using
I am trying to trigger the FB subscribe event, but the alert does not
Using the following code: <a href=/someurl> <div class='mydiv' onMouseOver=document.getElementById('myid').sendEvent('play'); onMouseOut=document.getElementById('myid').sendEvent('stop');> <div id='myid'></div> <script type=text/javascript>
I'm not subclassing the control. Trying to trigger the event via Control.Size = Control.Size
I am trying to fill in a form using Javascript/ajax/php but the problem is
Possible Duplicate: Reset JavaScript Counter? I'm trying to create a function that will trigger

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.