Jsobject. Call ()-communication between Applet and JavaScript

Source: Internet
Author: User
Jsobject. Call () Java methodname

Jsobject. Call () Java method --- invoke a method of a JavaScript Object

Availability

Part ofNetscape. JavascriptPackage completed ded with navigator 3.0

Synopsis

 

public Object call(String methodName, Object args[])
Arguments
Methodname

The name of the JavaScript method to be invoked.

 

ARGs []

An array of Java object to be passed as arguments to the method.

Returns

A Java object that represents the return value of the JavaScript method.

Description

TheCall ()Method of the Java jsobject class invokes a named method of the JavaScript Object represented by the jsobject. arguments are passed to the method as an array of Java objects, and the return value of the JavaScript method is returned as a Java object. chapter 19,Liveconnect: JavaScript and JavaDescribes the data conversion was med to convert the method arguments from Java objects to JavaScript values and to convert the method return value from a javascript value to a Java object.

 

 

Eg: the foreground obtains parameters to change the panel width. The width is defined as a global variable in the panel class. If the front-end sets the JS parameter to 99 or not empty, the size is changed to 630; otherwise, the value is 800.

In the applet, you can set the Code as follows:

Try <br/> {<br/> jsobject win = jsobject. getwindow (applet); <br/> Object ret = win. call ("ispreschedule", null); <br/> If (Ret! = NULL) {<br/> This. view_width = 630; <br/>}else {<br/> This. view_width = 800; <br/>}< br/> catch (jsexception e) <br/>{< br/> joptionpane. showmessagedialog (null, E. getmessage (); <br/> E. printstacktrace (); <br/>}

Here, ispreschedule is the ispreschedule function defined in the JS file, or the JS function defined in the script of the JSP page:

Function ispreschedule () {// to resize applet for double <br/> var iscore = 99; <br/> return iscore; <br/>}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.