Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Dynamic JS?

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic JS?

    Is this nuts ?

    Also, is there a better way to turn a string into code?

    Code:
    <html>
    <head>
    <title></title>
    <script>
    
    function f1() {
    JS_div = document.getElementById('JS')
    code = JS_div.innerHTML
    time1 = setTimeout(code, 1)
    }
    
    function f2() {
    JS_div.innerHTML = "clearTimeout(time2);alert(somevar)"
    code = JS_div.innerHTML
    time2 = setTimeout(code, 1)
    }
    
    </script>
    </head>
    <body>
    
    <input type="button" value="go" onclick="f1()">
    
    <div id="JS" style="display: none;">
    
    clearTimeout(time1);
    JS_div.style.display='block';
    alert('here');
    somevar = 'changed';
    f2()
    
    </div>
    
    </body>
    </html>

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    var fnSomething=new Function([string argumentName],* [string functionBody]);
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    liorean could you give me a for dummys version of that. What is * doing?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •