Jump to content

Java/JavaScript troubles


CarlosTheDwarf

Recommended Posts

I wrote a program in java and now need to integrate it in a browser, and not as a Applet.The program uses other files and I need a way to access them. I tried using AJAX but it didnt work out because i needed methods like next() and nextLIne(). Basically i need a replacement for the Scanner class.Ive tried a lot of things and I dont even know what language i will have to use to do what i want so i figured id post it here and hope for some coding master to come save me :) Mucho Grascias,Carlos

Link to comment
Share on other sites

Well, if all of the code is in Javascript then you can try a couple different methods to attach the external script files. One way, which I've seen Google use, is to just use a document.write statement within the HTML content. If you run the statement after the page finishes loading you'll have problems, but if it is inline in the HTML code then it will work to attach a new script file. In that case you need to close your first script block and then start another one to use the new code.

<script type="text/javascript">document.write("<script src=\"script.js\" type=\"text/javascript\"><" + "/script>");</script><script type="text/javascript">// use the code in script.js here</script>

You can also try creating a new script element and attaching it to the head.

sc = document.createElement("script");sc.src = "script.js";document.getElementsByTagName("head")[0].appendChild(sc);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...