Re: [問題] applet使用listfile的問題
我終於看懂了...
就不能替別人想一想,只留下第二種想法的 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
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):