Solved

JavaScript/Browser Navigation from Java in IE4

Posted on 1998-07-10
4
195 Views
Last Modified: 2010-08-05
Hi,

Can anyone tell me how I can get IE4 to go to a web page from within a Java Applet?  There are Java classes available for NN4 that allow you to call JavaScript from Java.  In JavaScript I can get the browser to do what I want.

so..
How can I call a JavaScript function from Java in IE4???
(or otherwise tell IE4 to load a web page)

Regards,
Maddy
0
Comment
Question by:maddy051398
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
fontaine earned 100 total points
ID: 1225737
You don't need to use Javascript to do this. Here is a sample applet that opens a new
browser window with the homepage of EE. There exists several options (new window,
or not, etc). Read the doc. of the showDocument() method of java.appplet.AppletContext.java
to know about them.

   import java.awt.*;
   import java.applet.*;
   import java.net.*;


   public class HTMLApplet extends java.applet.Applet {

       private Button button = new Button("Click me!");

       public void init() {
           add(button);
           return;
       }

       public boolean action(Event event, Object action) {
           

           try {
               URL url = new URL("http://www.experts-exchange.com");
               AppletContext context = getAppletContext();
               context.showDocument(url,"_blank"); // <-- pops up the window...
           } catch (MalformedURLException e) {
               e.printStackTrace();
           }
           return true;
       }
   }


0
 

Author Comment

by:maddy051398
ID: 1225738
That did the job, thanks!

Strange that the call to showDocument() takes about 5 seconds to display the requested page (2nd parameter set to "_self")..?

Oh well.

Regards,
Maddy.
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1225739
That's probably the time to establish the connection to the site.
0
 

Author Comment

by:maddy051398
ID: 1225740
Maybe my P166 just doesn't cut it anymore!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
thymeleaf natural templating vs JSP 2 104
diffSum example 4 37
table example 4 29
jsp insert to database example 2 24
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question