Calling a JavaScript function from an JApplet...

Can anyone help? Is it possible to call a JavaScript function from within a JApplet? If so, what is the syntax? I've seen reference to the Netscape package but I've been led to believe it doesn't always work within Internet Explorer 6 which is the target browser.
If the above is not possible can anyone tell me if and how it is possible to load images from outside the init() method of a JApplet? This would allow me to work around the problem.
Thanks in advance - Jim.

Call javascript you use the JSObject
Please note the MAYSCRIPT int the html file.
html file:
     <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
              height="0" width="0" >
        <param name="code" value="someApplet.class" />
        <!--[if !IE]> Mozilla/Netscape and its brethren -->
        <object classid="java:someApplet.class"
                height="0" width="0"
                mayscript=true>
        </object>
        <!-- <![endif]-->
      </object>
<LABEL id="lblOutputText">This text is the HTML text </LABEL>java class:
// new class for jsObject!!!! compile this: javac -classpath "C:\Program Files\Java\jre1.5.0\lib\plugin.jar" someApplet.java
// since jaws.jar does not exsist anymore
// in 1.4.0 to compile: javac -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
// for msjvm use the -source 1.3 -target 1.1 option so the command looks like this:
// javac -source 1.3 -target 1.1 -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
import netscape.javascript.*;
public class someApplet extends java.applet.Applet {
    JSObject win;
    public void init() {
         try{
             win = JSObject.getWindow(this);
// you need win.eval("window.close();"); // to close the window. if the current window is not a popup
// opened by a parent with window.open than the user will get a waring, your next question probably will
// be "can I stop this warning" and the answer is simple: NO
             JSObject textBoxLabel = (JSObject) win.eval("document.getElementById('lblOutputText')");
             textBoxLabel.setMember("innerHTML", "<center><h1>Some text</h1></center>");
        }catch(Exception e){
             e.printStackTrace();
}

Similar Messages

  • How to call a Javascript function from backing bean without any event

    Hi,
    Someone knows how to call a Javascript function from backing bean without any event ?
    thanks

    Please review the following thread:
    ADF Faces call javascript
    Luis.

  • Help needed in calling a javascript function from a jsp

    Hey guys,
    I need help.
    In my jsp I have a field called date. When i get date field from the database, it is a concatination of date and time field, so I wrote a small javascript function to strip just the date part from this date and time value.
    The javascript function is
    function formatDate(fieldName)
              var timer=fieldName;
              timer = timer.substring(5,7)+"/"+timer.substring(8,10)+"/"+timer.substring(0,4);
              return timer;
    Now I want to call this javascript function from the input tag in jsp where I am displaying the value of date. Check below
    This is one way I tried to do:
    <input size="13" name="startDate" maxLength="255" value=<script>formatDate("<%=startDate%>")</script> onChange="checkDate(this)">
    I even tried this:
    <input size="13" name="startDate" maxLength="255" value="'formatDate(<%=startDate%>)'" onChange="checkDate(this)">
    But it dosen't work
    Please help. I am struggling on this for days.
    Thanks,
    Ruby

    Hey all you developers out there , Pleaseeee help me with this one.

  • Is it possible to call a JavaScript function from a dialog?

    Hi there,
    At the moment I have created a dialog, that consists of three text fields that a user fills out, and then clicks next.
    What I am attempting to do, is pass the result of these three textboxes to a JavaScript function I have laying in a file in Web Resources. I've done some research, and I can't find anything.
    So my question is - is it possible to call a JavaScript function from a dialog?
    Thanks for your time.

    Hi,
         It is not possible unfortunately. We can start dialog from script but not the other way unfortunately. However, you can always write server side code for this and it will surely execute. So instead of javascript, write plug-in.
    Hope this helps.
     Minal Dahiya
     blog : http://minaldahiya.blogspot.com.au/
     If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

  • How to call a javascript function from XSL

    I'd a requirement to take an action each time a page loads
    I called the javascript function from addLoadEvent() available in javascript.
    But my reviewer commented that it should be called using XSL as we are using XSLT,
    What is preferred?
    To pass function name to the already available function or somehow call it from xsl ? if second is preferred option then,
    how to call a function through XSLT, if it is to be called aftr the page loads?

    Thank u..
    but i'd seen that link wen i searched in google..
    Is it possible without using any 3rd party JARs and all?
    and more importantly plz tell me what should be preferred way to call a javascript function?
    Do it using addLoadEvent() or Windows.Load etc
    OR
    Call it thru Xsl? (I donno how to do dis)
    Thanks in Advance..
    Edited by: ranjjose on Jun 3, 2008 8:21 AM

  • How do you call a JavaScript function from a Java applet

    I have an Applet that needs to run on the following platforms: Internet Explorer (Windows-NT, Windows -2000), Netscape (Windows-NT, Windows-2000, Sun(Solaris), RedHat(Linux), HP(11.0), IBM(AIX)).
    The Applet needs to call a JavaScript function that is included on the HTML page that contains the applet. In JRE-1.3.1 I used the AppletContext.showDocument(url,"_self" ) where the url is "javascript:MyScript('param1')". This works just fine. I tried using showDocument without the second parameter and all the other choices for the second parameter and none of them worked (nothing happened).
    I tried the same code with JRE version 1.4-beta. It seems that version 1.4-beta no longer supports a URL that starts with "javascript" in the AppletContext.showDocument(url,"_self" ) method. The error is:
    netscape.javascript.JSException: call does not support self.open
    at sun.plugin.javascript.navig.Window.call(Unknown Source)
    at sun.plugin.ActivatorAppletContext.showDocument(Unknown Source)
    I tried to catch the JSException but I cannot seem to.
    I then tried a completely different approach. I then grabbed the JSObject for the page and tried to call my javascript function (MyScript) directly:
    JSObject theObj = JSObject.getWindow(this);
    Object paramArray[] = new Object[1];
    paramArray[0] = Param1;
    theObj.call("MyScript", paramArray);
    This worked fine on Netscape[Windows-NT, Windows-2000]. HP throws a JSException on getWindow() and Solaris just hangs. I did not even try IE.
    What is the recommended approach here?

    you can try this, it worked for me:
    JSObject win = JSObject.getWindow(this);
    win.eval(function_call);
    I have other ways also, so if this doesn't work, let me know.

  • Calling a javascript function from java code and getting tha value in Java

    Hi,
    I would like to call a Java script function confirmRemove() from Java code upon meeting a condition..
    for example the code snippet is:
    if(true){
    // I want to call js confirmRemove() over here. And get the value of variable "answer" in this if block.
    <html>
    <head>
    <script type="text/javascript">
    function confirmRemove() {
         var answer = confirm("Are you sure you want to Delete?")
    </script>
    </head>
    <body>
    <form>...

    Hi,
    Back in 2003 I have used an Applet which contain java code and this java code was calling the java scripts ( different methods, DHTML etc..)
    There was a component developed by NetScape called JSObject I am not sure it there is other third party component other then the JSObject
    look at this article which shows how (based on JSObject)
    [http://java.sun.com/products/plugin/1.3/docs/jsobject.html|http://java.sun.com/products/plugin/1.3/docs/jsobject.html]
    Regards,
    Alan Meio
    London,UK

  • Calling a javascript function from an Applet

    I am trying to make an applet that works on as many browsers as possible, so I am sticking to Version JCK 1.1
    I am trying to call pass the javascript function into a URL object like this
    URL url = new URL("javascript:" + function, "_self");but I keep getting a MalformedURLException. I've read some of the other comments, but they all say to use the netscape.javascript package and the JSObject class, but I can't find that object anywhere inside the API posted on Sun's website.
    Any help would be greatly appreciated.

    To access JavaScript methods, properties, and data structures from your Java applet, import the Netscape javascript package:
    import netscape.javascript.*
    public class myApplet extends Applet
    {   public void init()
    {     /* Use the following syntax to call JavaScript methods:*/
    JSObject.getWindow().eval("expression")
    /*expression is a JavaScript expression that evaluates to a JavaScript method call. */ }

  • Calling a JavaScript function from my class

    Here's the situation. I am trying to access a website (not my own) through a class I am writing. Some information that I need to pull off the page can only be seen when a JavaScript function is called. How can I make the page call the function from my own computer?

    Well, you could use a tool like this:
    http://httpunit.sourceforge.net/
    If the Javascript you want to call into is relatively simple it may work ok for you, but there's no guarantee - differences between the browser's libraries and the Rhino (Java's embedded Javascript) libraries may make the exercise intractable.
    You might alternatively be able to invoke the browser from Java and then screen scrape it somehow, but I can't help you with that - and it's a distinctly inelegant solution.
    If you have a legitimate reason for doing this, your best bet would be to contact the website owner and see if they can accommodate you somehow; they may even have a suitable services API for you to call into without messing about trying to render the Javascript. If you don't have a legitimate reason for doing this (one the website owner would be ok with) then my sympathy for your plight is rather limited anyway.

  • Call PDF Javascript Function from External HTML Document

    Greetings,
    Forgive me if this information has been posted previously - I've searched quite a bit and haven't quite found anything specific or similar.
    We have LiveCycle Designed forms, and are including the Form in an IFRAME within an HTML page.  From there, we would like to be able to call one of the functions we've added to the LiveCycle form.
    So for example,
    <HTML>
    <HEAD><TITLE></TITLE>
    <SCRIPT type="text/javascript">
    function CallFunc()
    window.PDFFrame.TestFunc();
    </SCRIPT>
    </HEAD>
    <BODY>
    <iframe src="MyPDFFile.pdf" width="100%" height="100%" name="PDFFrame" id="PDFFrame"></iframe>
    </HTML>
    The "window.PDFFrame.TestFunc()" is where I'm running into issues.  I have tried to use PDFFrame.xfa.etc, and PDFFrame.document.etc, but I'm not sure of the appropriate method to access this PDF Document's functions.
    I do have a "TestFunc()" defined (tested and working) in the PDF document (designed in LiveCycle).
    Any advice is much appreciated -
    Thanks!

    I have attempted to use the information found here for this task:
    http://livedocs.adobe.com/flex/3/html/help.html?content=PDF_1.html
    But is this outdated?  Using the LiveCycle Designer, I have not been able to utilize the "this.hostContainer.messageHandler" with any success.  Is their an equivalent xfa.etc handler?  Or if "this.hostContainer.messageHandler" is still available to Acrobat 9.X documents, what are the appropriate steps to using this?  I've tried putting it in the document initializer, docReady, and Page events and it doesn't seem to be available in any of those.
    Any advice is appreciated,
    Thanks!

  • Can we call a javascript function from backing bean class?

    I have a requirement. In a multiselect table, when users selects some rows and clicks a button. Depending upon some condition, an alert box should appear with 2 buttons 'Yes' and 'No'. On clicking yes, certain field values in the selected rows of table should change. On clicking no, the alert box should close. As far as i know alert box can be done only in JS.
    Please help me, if a javascript function can be called in backing bean method or suggest some way where alert boxes can appear through ADF.

    I need to go back to the backing bean as i need to iterate through each selected row of the table in a method( method written for command button) and then if atleast one of the selected rows has job field='Manager', then an alert box needs to be displayed. If none of the rows have job field as 'manager', alert box should not be displayed.
    If I write the function for onclick, i cannot iterate through the selected rows of the table in JS function.
    Please suggest a way to do this.

  • Calling a javascript function from Flash

    Maybe someone out there can help?
    I'm trying to set a variable in AS3 and then use an event to call that variable.  The links are set in an xml file.  I have it working with hyperlinks using navigateToURL, but it's not doing exactly what I want.   What I want is to use flash to call the link in the xml file.  That link will target a javascript function. There is no need to open a new window.  I'm trying to target a particular div on the page.   Here's what I have so far:
    import flash.net.navigateToURL;
    import com.flashloaded.as3.PhotoFlowEvent;
    function eventHandler (eo:PhotoFlowEvent):void {
    var request:URLRequest = new URLRequest(eo.data.link);
    navigateToURL (request,"_self");
    <?xml version="1.0" encoding="utf-8"?>
    <photos path="images/">
       <photo name="photo1" url="1.png" link="javascript:loadContentA();">This is photo 1</photo>
    </photos>
    I'm thinking there must be a way to set the variable and then use ExternalInterface in flash to do the rest of the work?
    any help is greatly appreciated!    Cheers!

    <script type="text/javascript">
    function loadContentA(elementSelector, sourceUrl) {
        $("#mainContent").load("ad01.html");
    </script>
    <?xml version="1.0" encoding="utf-8"?>
    <photos path="images/">
       <photo name="photo1" url="1.png" link="javascript:loadContentA();"></photo>
    </photos>
    import flash.net.navigateToURL;
    import com.flashloaded.as3.PhotoFlowEvent;
    function eventHandler (eo:PhotoFlowEvent):void {
    var request:URLRequest = new URLRequest(eo.data.link);
    navigateToURL (request,"_self");
    photoflow.addEventListener (PhotoFlowEvent.CLICK_SELECTED, eventHandler);

  • Is it possible to call a JavaScript function from a FormCalc script?

    Greetings:
    I am wondering if there is a way to call a function coded in JavaScript from a field event that is coded in FormCalc in Designer 8.
    If so, I should be able to reference the same global variables in each language correct?
    Best Regards:
    Mark

    Thanks Srini!
    That is what I want to do.  I have tables that I have simple FormCalc calculations on to total the fields.  I want to then compare the totats of the fields to make sure they are equal.  That is where I am using the if else statment with JavaScript.  But for some reason it isn't working.It is the first part of my IF statement that doesn't do anything - when I go to the form and make them all equal I don't get the "boo" message (I am just trying to learn )
    thanks!
    Jodi
    var myDoc = event.target;
    var CashCheckTotal = myDoc.getField("form1[0].#subform[0].CalculatedCashCheckTotal[0]");
    var DescTotal = myDoc.getField("form1[0].#subform[0].CalculatedDescriptionTotal[0]");
    var FoapTotal = myDoc.getField("form1[0].#subform[0].CalculatedFoapTotal[0]");
    var curDate=new Date();
    var PartNetID = myDoc.getField("form1[0].#subform[0].NetID[0]").value;
    var dialogTitle = "Please Confirm that the email was sent and the form was printed"; 
    var defaultAnswer = "Yes"; 
    var f = myDoc.getField("form1[0].#subform[0].Campus[0]"); 
    var cbStatus1 = (f.isBoxChecked(0)) ? "OK" : "not"; 
    var cbStatus2 = (f.isBoxChecked(1)) ? "OK" : "not"; 
    var cbStatus3 = (f.isBoxChecked(2)) ? "OK" : "not"; 
    if("CashCheckTotal" == "DescTotal"
    & "DescTotal" == "FoapTotal")
        {xfa.host.messageBox("Boo")}
    else {xfa.host.messageBox("Totals are not equal or are zero:\n" + "Calculated Description Total(A), Calculated Cash/Check Total(B) and Calculated CFOAPAL Total(C) must be equal.");}

  • How to call a javascript function from oracle apex 3.2.1 (oracle 11g)

    Hello ,
    I want to use javascript for client side validations in oracle apex 3.2.1 and i am using oracle 11g.
    how to call a function for a submit button where i will validate the existance of data for a control and submit the page once validated.
    where to place the call to a fucction and where the function need to be written.
    please give me a sample code...
    i am new to oracle apex.
    thanks/

    Hi,
    This might help
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/javascript.htm#CIHEBFFC
    Br,Jari

  • Calling a javascript function from another javascript

    Hi,
    How can I call a java script functon implemented in java script file JS1, from another java script file say JS2. In fact I can copy the same method and can go ahead but it will add to the code redundancy.
    Any help will be highly appreciated.
    TIA.

    If you are indeed talking about JavaScript, then you are definitely in the wrong forum. This forum is about Java, which has nothing to do with JavaScript at all.

Maybe you are looking for

  • F4 help in ALV report output  (FM REUSE_ALV_GRID_DISPLAY)

    Hello, I have developed ALV report using the FM REUSE_ALV_GRID_DISPLAY. My requirement is to have a customized search help on the output of ALV on one field. I tried to find it on SDN but all the methods are using OO ALV. How we can attaché customize

  • How to get the File name that File Adapter is giong to write to a directory

    Hi, I am really stuck at one pint while working with File Adapter/FTP Adapter. My requirement is I need to read a message from the Queue and write it to a directory as a physical file using a File/FTP adapter and the name that adapter will give to th

  • Setting up 4 iMacs in retail store - help, please

    Greetings, all. I am in the retail cellular phone business. Opening a new store soon, this one a Cingular authorized dealership. I'd like to use Intel iMacs throughout the store, and am looking for some advice on how to best set things up, as I am st

  • Search Results Panel

    Greetings All, Say I search a folder for pages with links to a specific CSS file and 50 pages are returned in the Results panel-is it possible to open all the files from within the Results panel? I've tried selecting all the files and right-clicking

  • Podcast headers remain after deleting usnig the swip method added in 2.2

    I have a 2nd gen iPod Touch with firmware 2.2 and I am able to delete podcasts with the swip method and it says it deletes them and they are removed from the list. The problem is that if I shut the touch off and turn it back on, all of the podcasts I