Trying to call an applet method using JavaScript will not be successful

When trying to invoke methods of a Java applet using JavaScript, I encounter an issue that requires the site to be added to trusted sites and security set to low in order for it to work properly. Otherwise, an error is thrown:

Microsoft JScript runtime error: Object doesn't support property or method 'myMethod'

I am wondering how I can resolve this issue.

In Chrome, a prompt appears asking if I want to execute the applet.

Snippet of the full code used:

<html>
<head>
<script type="text/javascript">
    function getKey() {
    var key = document.myApplet.myMethod();
    }
</script>
</head>
<body onload="getKey()">
<applet id="myApplet" archive="myApplet.jar" code="myApplet.class" width="0" height="0"></applet> 
</body>
</html>

Answer №1

Instead of using the outdated applet tag, switch to using an Object tag as shown below:

<object type="application/x-java-applet" width="0" height="0" name="appId">
   <param name="code" value="myApplet" />
   <param name="archive" value="myApplet.jar" />
</object>

Update your Javascript code like this:

function getKey() {
   var key = appId.mymethod();
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Consider developing a custom plugin that automatically loads all components within your nuxt.js application

I have been attempting to load and define all my components globally in nuxt.js. However, I encounter an error when trying to load the *.vue file: "Cannot find module ....". Despite the fact that the file exists in the specified location... Below is the ...

Top spot for placing a file containing a polyfill to ensure cross-browser compatibility in JavaScript projects

Curious about the best location within a React / Redux app (built with create-react-app) to store custom polyfill files for browsers that do not support certain features. I specifically require Array.prototype.includes and String.prototype.startsWith, as ...

Multi-Tenant Spring Batch - Optimizing Your Data Processing

It seems like I've encountered a common issue with Spring that others may have already solved, but it's currently beyond my comprehension. I have a Spring Boot (2.2.4) application where I'm utilizing Spring Batch to read records from a text ...

Integrate an input field with a copy function similar to the GitHub clone view

Can anyone help me create a view with a tooltip similar to the one on Github? You can see the example here: https://i.sstatic.net/iBSof.png I attempted to use CSS but couldn't quite replicate the exact UI. Here is my current CSS code: [tooltip] { ...

Navigating Through Secondary Navigation with Ease

In my React project, I am developing a mega-menu styled dropdown navigation. As a functional component, I am utilizing the useState hook to manage the state and control the display of sub-navigation items. The functionality of the dropdown is operational, ...

Using jQuery to search for corresponding JSON keys in the PokéAPI

Currently, in my development of an app, I am searching for and implementing an English translation of a language JSON endpoint using the PokéAPI. The challenge lies in identifying the correct location of the English language key within the array response, ...

A node.js library that allows for seamless integration of Java code

Are there any node modules that allow for calling Java code directly from Node.js? I'm looking to execute a basic Java application using Node. In addition to the node-java module, are there any other modules in Node.js that can achieve this function ...

Ways to determine the number of duplicate items in an Array

I have an array of objects that contain part numbers, brand names, and supplier names. I need to find a concise and efficient way to determine the count of duplicate objects in the array. [ { partNum: 'ACDC1007', brandName: 'Electric&apo ...

Update input box value using Javascript

Here is the code for a <script> tag on a webpage that includes an input box within the body of an HTML document- <script type="text/javascript" language="JavaScript"> window.onload = function addSearchText() { document.getElementB ...

The unrevealed node that is requesting the module is leading to an undefined outcome

I'm facing an issue where I need to import var server = require('../../index.js'); in my foo-dao.js file. This is necessary for accessing a hapi server plugin without passing it through the hapi request object from controller to dao. The pr ...

Counting the number of PHP inputs in a field

Hello, I am using a PHP script from Steve Dawson's website. To display the output on my HTML page, I am utilizing this AJAX script: <script> $.ajax({ type:'GET', url:'http://www.solariserat.se/count.php', data: ...

Protractor Encounters Error When Assigning Variable

var itemStatus = element(by.model('item.statusId')).getText(); This issue is causing Protractor to raise an error: Uncaught exception: Error while waiting for Protractor to sync with the page: "Angular could not be found on the window" Pro ...

I am attempting to retrieve an OTP from a MySQL database and send it as a password. The challenge now is figuring out how to use Java Selenium WebDriver to send

enter code here: public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Users\\admin\\Documents\\selenium ...

Implementing the fetch API with radio buttons in a React Native application

I found a useful package for radio buttons called react-native-flexi-radio-button. Currently, I'm working on displaying API results within radio buttons. The API response provides 4 options, and my goal is to render text alongside the corresponding ra ...

Adjust the active carousel item to 0 within onsen-ui (displaying a list of carousel items in a sliding menu)

In my sliding menu, each menu item contains a carousel with two items. I am trying to make the first carousel item show after closing and reopening the menu, or by clicking a button outside of the list on the menu page. This is my current setup: <ons- ...

Is the input in the array? How to find out?

I am currently facing an issue with a script that I have created to count array elements matching a user input. Strangely, all if statements in the script seem to be returning false. I have verified that both the array element and the input value are stri ...

Insert a new row into the table using jQuery right above the button

I am working on a table where I need to dynamically add rows in the same rowId upon clicking a specific button. For instance, when the "Add Row 1" button is clicked, a new row should be added under "Some content 1", and so on for other rows. <table i ...

React - The `component` prop you have supplied to ButtonBase is not valid. Please ensure that the children prop is properly displayed within this customized component

I am attempting to use custom SVG icons in place of the default icons from Material UI's Pagination component (V4). However, I keep encountering this console error: Material-UI: The component prop provided to ButtonBase is invalid. Please ensure tha ...

Struggling to dynamically create form controls within Angular forms and receiving the following error in the console: "TypeError: feature_r5.get is not a function"

When I click a button in my Angular v14 HTML template, I am trying to dynamically generate form controls and although I am able to generate them, an error is popping up in the console. ERROR TypeError: feature_r5.get is not a function at PostAdvComponent_ ...

Deleting a row from a table in Angular when a form is submitted

I am new to using Angular and I have been attempting to remove certain elements from a table upon submission. <tr ng-repeat="val in values "> <td ng-bind="$index"></td> <td ng-bind="val.rec">ED1500322</td> <td& ...