import java.applet.Applet; import java.awt.*; import java.net.*; public class URLTargetFix extends Applet { Button _firstButton; public void init() { setLayout(new BorderLayout()); _firstButton = new Button("Click Here For Target = _mytarget"); add("Center", _firstButton); } public boolean handleEvent (Event event) { if (event.target == _firstButton && event.id == Event.ACTION_EVENT) { loadURL("../Html/first.html", "_mytarget"); return true; } return super.handleEvent(event); } private void loadURL (String urlName, String target) { URL u = null; try { u = new URL(getCodeBase(), urlName); } catch (MalformedURLException e) { System.out.println("Maformed URL Exception Thrown"); } getAppletContext().showDocument(u, target); // Add it twice for Mac -- Note adding twice // for other platforms doesn't really do any // harm, but I use this extra code just in case // // For example, note that I am not checking for // the netscape version. The bug seems to have // disappeared in Netscape v4.x. But it could // still be in older Netscape 4.x versions and // it doesn't do much harm to call the method // twice anyway. // String osName = System.getProperty("os.name").toLowerCase(); String browser = System.getProperty("java.vendor").toLowerCase(); if ((osName.indexOf("mac") != -1 && browser.indexOf("netscape") != -1)) { getAppletContext().showDocument(u, target); } } }