作者PsMonkey (痞子军团团长)
看板java
标题Re: [问题] applet使用listfile的问题
时间Thu Nov 1 15:48:11 2012
我终於看懂了...
就不能替别人想一想,只留下第二种想法的 code 吗?
※ 引述《BossPi (皮老板)》之铭言:
: import java.applet.Applet;
: import java.io.File;
: public class test extends Applet{
: private String meg = "";
: public void setMeg(String str){
: meg = str;
: }
: public void pro(){
: System.out.println("Parameter : "+meg);
: File filedir = new File(getParameter(meg));
: File[] files = filedir.listFiles();
: for(int i=0 ; i<files.length ; i++){
: File fileList = files[i];
: System.out.println(fileList.getName());
: }
: System.out.println("ok");
: }
: }
: -----------test.html----------
: <html>
: <head>
: <meta http-equiv="Content-Type" content="text/html; charset=big5">
^^^^^^^^^^^^
这种害人的东西就别再用了
: </head>
: <script>
: function a(){
: var form = document.form1;
: var id = form.name.value;
: var pwd = form.password.value;
: var app = document.all('test');
: app.setMeg(id);
: app.pro();
: }
: </script>
基本上这快要炸到版规 2.1 了
不过 applet 本来就是在网页上的东西,就... (等另一个版主来水桶我? XD)
document.all 这个基本上只有 IE 能用
因为你没有注明是用哪个浏览器
所以非常有可能会炸在这里
请改用 document.getElementById() 之类(比较)通用的 JS method
不然你就在 js 当中 alert(app) 看会不会有东西就知道了
本 thread 有违反版规嫌疑,所以全部锁定
: <body >
: <p align="center">
: <applet code="test.class" name="test" archive="Demo3.jar">
: <PARAM NAME="par" VALUE="C:/">
: </applet>
: </body>
: </html></p>
: <form method="POST" name="form1">
: <p> </p>
: <p>id:<input type="text" name="name" size="20"></p>
: <p>pwd<input type="text" name="password" size="20"></p>
: <p>
: <input type="button" value="ok" onclick=a();></p>
--
钱锺书:
说出来的话
http://www.psmonkey.org
比不上不说出来的话
Java 版 cookcomic 版
只影射着说不出来的话
and more......
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.202.140