不用搞什么事件
showDocument()方法相当于做了个超链接,你点击会自动打开
showDocument(URL url,String target);
target可以取下面几个参数:
"_self" 在本框架或窗体打开
"_top" 顶层
"_blank" 新窗体
"_parent" 父窗体打开
showDocument()方法相当于做了个超链接,你点击会自动打开
showDocument(URL url,String target);
target可以取下面几个参数:
"_self" 在本框架或窗体打开
"_top" 顶层
"_blank" 新窗体
"_parent" 父窗体打开
import java.net.MalformedURLException;
import java.net.URL;private void ShowHTMLPage(String s, String s1)
{
AppletContext appletcontext = applet.getAppletContext();
URL url = null;
try
{
url = new URL(s);
}
catch(MalformedURLException malformedurlexception)
{
DisplayMsg(malformedurlexception.getMessage());
}
appletcontext.showDocument(url, s1);
}
ct.showDocument ("http://www.ncsa.uiuc.edu:8080/demoweb/url-primer.html ");
改为
ct.showDocument ("http://www.ncsa.uiuc.edu:8080/demoweb/url-primer.html","_blank");
试试。
2、s1可以取下面几个参数:
"_self" 在本框架或窗体打开
"_top" 顶层
"_blank" 新窗体
"_parent" 父窗体打开
import java.net.*;
import java.awt.*;
public class Applet1
extends Applet { //Construct the applet
public Applet1() { } //Initialize the applet
public void init() { }
public boolean mouseDown(Event e,int x,int y)
{
AppletContext appletcontext = this.getAppletContext();
URL url = null;
try {
url = new URL("http://www.sohu.com");
}
catch (MalformedURLException malformedurlexception) { }
appletcontext.showDocument(url, "_blank"); return true;
}
}