|
Q1306 How can I hold a reference to the current object instance?
irt.org | Knowledge Base | JavaScript | Object | Q1306 [ previous next ]
Q1306 How can I hold a reference to the current object instance?
If you need to hold lots of references all at once, and don't want a
subsequent reference to be overwritten by another then try something
like:
<script language="JavaScript"><!--
// define the myString object
function myString(value) {
this.value = value;
var now = (new Date()).getTime();
eval('tmp' + now + ' = this');
setTimeout('alert(tmp' + now + '.value)',1000);
}
// create an instance of a myString object
var mytext1 = new myString('this is a test');
var mytext2 = new myString('this is another test');
//--></script>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.