in the opened page, opener.setPic(param); memo:the method setPic() is a function in the page which contains the applet.In this function,you can call a method in the applet like this:document.app1.setPicText(param). ("app1" is the applet's name).LUCK!
Servlet :A.class Applet :B.class 被打开的网页:c.htmc.htm里,比如点击一个按钮“选择”,在触发的事件里写上: <script> function select(){ opener.setPic(param);//param即为你要返回的结果 window.close(); } </script>A.class里:<script> function setPic(param){ //app1是applet的名字,setPicText(param)是applet里 //定义的方法 document.app1.setPicText(param); } </script> <applet name="app1"...............>B.class里,以把选择的结果显示在文本框里为例://一定要定义为public public void setPicText(String txt){ tf.setText(txt);//tf为文本框 } 我就知道这些了,不知能不能解决你的问题?
B.jsp中可以用 opener.close()关闭A.jsp >:你关A.jsp干嘛?后面的问题,我想可能是因为你用的是NetScape。我在用NetScape4.79调的时候总是报opener has no properties的错误。我的解决方法是:在B.jsp: document.cookie = param;在A.jsp: var par = document.cookie; <body onfocus = "setPic(param)">语句不完全正确,只是说明了一下思路。
我用opener.close()函数只是为了说明B可以调用A中的系统自带函数但是B中不能执行A中的我自定义的函数,比如: <script> function setPic(){ window.close(); } </script>我已经没有用任何参数,我只是想验证B能不能执行A的函数,我用的浏览器是IE6.0,我也不知是怎么回事,大概是Script语句有问题
getAppletContext().showDocument(URL url,String title);2. return value:
in the opened page, opener.setPic(param);
memo:the method setPic() is a function in the page which contains the applet.In this function,you can call a method in the applet like this:document.app1.setPicText(param). ("app1" is the applet's name).LUCK!
Applet :B.class
被打开的网页:c.htmc.htm里,比如点击一个按钮“选择”,在触发的事件里写上:
<script>
function select(){
opener.setPic(param);//param即为你要返回的结果
window.close();
}
</script>A.class里:<script>
function setPic(param){
//app1是applet的名字,setPicText(param)是applet里
//定义的方法
document.app1.setPicText(param);
}
</script>
<applet name="app1"...............>B.class里,以把选择的结果显示在文本框里为例://一定要定义为public
public void setPicText(String txt){
tf.setText(txt);//tf为文本框
}
我就知道这些了,不知能不能解决你的问题?
chinaillboy(浪漫)去取分吧,不用答贴
客气:)你说的方法我试了一下,的确可以。
opener.document.app1.setPicText(param);
在A.jsp里面有一个名字是appl的applet
appl打开了B.jspB.jsp中可以用 opener.close()关闭A.jsp但是B.jsp不能调用A.jsp里面用script写的方法,例如
opener.setpic();调用不成功而且B.jsp也不能调用appl里面的方法,例如
opener.document.appl.setPicText()也不能成功
请问什么原因?
>:你关A.jsp干嘛?后面的问题,我想可能是因为你用的是NetScape。我在用NetScape4.79调的时候总是报opener has no properties的错误。我的解决方法是:在B.jsp:
document.cookie = param;在A.jsp:
var par = document.cookie;
<body onfocus = "setPic(param)">语句不完全正确,只是说明了一下思路。
<script>
function setPic(){
window.close();
}
</script>我已经没有用任何参数,我只是想验证B能不能执行A的函数,我用的浏览器是IE6.0,我也不知是怎么回事,大概是Script语句有问题
我在IE5.0下没问题。1.仔细检查你的语句:
你在B.jsp里写的是opener.setpic();但在A.jsp里定义的是setPic()。2.如果还不行,换个浏览器试试。