I am trying to do what is most likely impossible. In JavaScript I want to
know the variable name that a new object is assigned to from within the
object. For example, if I do this

var testObject = new TestObject();

then the TestObject object will, with some magic function, get the
assignment variable name which in the above case is "testObject". I'm
thinking that the caller or callee property might be of use.

function TestObject()
{
// constructor
{
// constructor stuff here
var html = "";

var assignmentName = SomeMagicFunction(); // ??? where's the magic

html += "<img onClick='" + assignmentName + ".DoThisFunction()'>";

document.writeln(html);
}
}

If this is impossible, I'll just pass the assignee name as a parameter to
the object. Just wanting to make the object as smart as possible.

Thanks,

Mike

Re: Strange JavaScript Question by Steve

Steve
Fri Jun 27 19:56:18 CDT 2008

Ok, exactly what are you trying to do when you click on an image?
Open it in a new page or window?

If so, take a look at the source in this page that I forgot was still on my server until just now:
http://www.95isalive.com/test/

You'll need to allow pop ups if you want to see what it does.

--

Steve Easton
Microsoft MVP FrontPage
FP Cleaner
http://www.95isalive.com/fixes/fpclean.htm
Hit Me FP
http://www.95isalive.com/fixes/HitMeFP.htm



"Mike McCollister" <MikeMcCollister_DELETEME_@hotmail.com> wrote in message
news:150B72BD-2DBB-4147-BB20-1A9C8A6AEEAB@microsoft.com...
>I am trying to do what is most likely impossible. In JavaScript I want to know the variable name that a new
>object is assigned to from within the object. For example, if I do this
>
> var testObject = new TestObject();
>
> then the TestObject object will, with some magic function, get the assignment variable name which in the
> above case is "testObject". I'm thinking that the caller or callee property might be of use.
>
> function TestObject()
> {
> // constructor
> {
> // constructor stuff here
> var html = "";
>
> var assignmentName = SomeMagicFunction(); // ??? where's the magic
>
> html += "<img onClick='" + assignmentName + ".DoThisFunction()'>";
>
> document.writeln(html);
> }
> }
>
> If this is impossible, I'll just pass the assignee name as a parameter to the object. Just wanting to make
> the object as smart as possible.
>
> Thanks,
>
> Mike
>