Elnof Posted February 20, 2008 Share Posted February 20, 2008 My Javascript code is unable to access any of my java code. Where's my problem?java script: function getFile(pURL) { var text; document.getElementById('mainText').innerHTML = "<p>Loading Text...</p>"; text = document.textReadApp.javascriptCommandReadFile(pURL); if(text != "-1") { repairText(text); } else { document.applets("textReadApp").innerHTML = "<p>Error in load</p>"; }}function repairText(string) { var text; var text2; var homeLink = "<a onClick=\"getFile('addon/text/home.ntk')\" class=\"homeLink\">Home</a>"; text = String.replace(/~h~/gi, homeLink); text2 = text.replace(/~p~/gi, "<p>") text = text2.replace(/~!p~/gi, "</p>"); text2 = text.replace(/~img~/gi, "<img src=\""); text = text2.replace(/~!img~/gi, "\" />"); text2 = text.replace(/~sup~/gi, "<a href=\"#footNotes\"><div class=\"sup\">"); text = text2.replace(/~!sup~/gi, "</div></a>"); text2 = text.replace(/~n~/gi, "<br />"); text = text2.replace(/~l~/gi, "<hr class=\"textLine\" />"); placeText(text);}function placeText(finText) { document.getElementById('mainText').innerHTML=finText;} And my java: import java.awt.*;import java.io.*;import javax.swing.*;public class webTextReader extends JApplet { /** * */ private static final long serialVersionUID = 1L; /** * @param args */ public String javascriptCommandReadFile(String path) { try{ // Open the file that is the first // command line parameter FileInputStream fstream = new FileInputStream(path); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; String result = null; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console result += strLine; } //Close the input stream in.close(); return result; } catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } return "-1"; } public static void main(String args[]) { }} Everytime I try to run it, I get: Error: Object doesn't support this property or method. Why is it doing this? I've tried it on IE7 and FireFox 2.0.2. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 20, 2008 Share Posted February 20, 2008 document.textReadApp.javascriptCommandReadFile(pURL);I believe there should be either a getElementById in there, or the document.applets collection. Link to comment Share on other sites More sharing options...
Elnof Posted February 20, 2008 Author Share Posted February 20, 2008 I've tried both of those, and I got the same result. I'll try again tomorrow, but I don't think that it will help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.