dynamically generating javascript statements

Discussion in 'Javascript' started by Volker Hetzer, Oct 29, 2003.

  1. Hi!
    I'm new to javascript and I'd like to know whether javascript can
    process javascript-code entered by the user or read from a file.

    We've got an application that uses ActiveX as main customization
    means and we'd like to write a javascript control which listens
    to a socket, reads a javascript statement accessing some ActiveX classes
    and then executes that statement. The applicatoin doesn't know beforehand
    which classes are there.

    Lots of Greetings!
    Volker
     
    Volker Hetzer, Oct 29, 2003
    #1
    1. Advertisements

  2. Yes, the function
    eval
    takes a string with JavaScript source code as its arguments and
    evaluates the code.
     
    Martin Honnen, Oct 29, 2003
    #2
    1. Advertisements

  3. Perfect!
    Thanks a lot!
    Volker
     
    Volker Hetzer, Oct 29, 2003
    #3
  4. JRS: In article <3f9fde6c$>, seen in
    And <URL:http://www.merlyn.demon.co.uk/js-quick.htm> does just the
    former that, when the Eval button is pressed.

    H'mmm - it can read from a file, too, if one enters something like


    <script type="text/javascript" src="include1.js">
    </script>
    <script type="text/javascript">
    document.write(LZ(3))
    </script>

    and presses HTML. Function LZ is supplied by include1.js.
     
    Dr John Stockton, Oct 29, 2003
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.