Jump to content

Java/JavaScript troubles


CarlosTheDwarf
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...