G
graphicsxp
Hi,
Consider the following code :
<script type="text/javascript">
function Test() {
this.init();
}
var t = Test.prototype;
t.init = function() {
this.name = 'Test';
eval(this.name + '=this');
}
function create() {
var t = new Test();
}
</script>
<input type="button" onclick="create()" />
The first time the button is clicked, it creates an instance of Test
and the init function is called. However if the button is clicked
again, an exception is raised : 'Object doesn't support this action'.
If I comment the line eval(this.name + '=this'); , then there is no
more error.
I'm trying to understand what is the issue there. Is there some code
I could run before I re-create the object in order to destroy the
previous instance ?
Thanks
Consider the following code :
<script type="text/javascript">
function Test() {
this.init();
}
var t = Test.prototype;
t.init = function() {
this.name = 'Test';
eval(this.name + '=this');
}
function create() {
var t = new Test();
}
</script>
<input type="button" onclick="create()" />
The first time the button is clicked, it creates an instance of Test
and the init function is called. However if the button is clicked
again, an exception is raised : 'Object doesn't support this action'.
If I comment the line eval(this.name + '=this'); , then there is no
more error.
I'm trying to understand what is the issue there. Is there some code
I could run before I re-create the object in order to destroy the
previous instance ?
Thanks