< Prev
Next >



Applet opening another webpage





In this article, we will show you how to make an applet(running in a webpage) open a new webpage in the new tab of the browser. This will be accomplished by showDocument() method of AppletContext interface. AppletContext interface gives us the access to the environment in which an applet is running and through this enviroment we can open a new webpage in the web browser.





Signature of showDocument() method


void showDocument(URL url, String str)
where, url is the location of the new webpage that we want to open from our applet and String value str describes where to display this new webpage. str could take a few values like -




Note -:


Due to new security restrictions imposed by many browsers, applets aren't allowed to run in Google Chrome, Mozilla Firefox, though we can still run applets within a webpage in Internet Explorer but only after making certain changes in the configuration of Java on our system. So, this example is based on opening an applet in a webpage within the Internet Explorer browser.




Points to remember before running an applet from within a webpage.





As soon as you click on the button "Allow blocked content", your applet contained in Sample.htm opens up and it also opens up another webpage Hello.htm in a new blank tab of browser.


Sample.htm


Hello.htm

As you may see, an applet Applet15 linked to a webpage Sample.htm has opened another webpageHello.htm



Please share this article -





< Prev
Next >
< Resizing an Applet
Swing Applets >
Please subscribe our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
-
C++ and Python

Ad2