...

View Full Version : Dynamic JS?



Graeme Hackston
04-01-2003, 12:56 AM
Is this nuts ? :eek:

Also, is there a better way to turn a string into 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>

liorean
04-01-2003, 01:29 AM
var fnSomething=new Function([string argumentName],* [string functionBody]);

Graeme Hackston
04-01-2003, 01:38 AM
liorean could you give me a for dummys version of that. What is * doing?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum