(Msg. 1) Posted: Fri Jun 27, 2008 6:19 pm
Post subject: Strange JavaScript Question Archived from groups: microsoft>public>frontpage>programming (more info?)
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.
(Msg. 2) Posted: Fri Jun 27, 2008 8:56 pm
Post subject: Re: Strange JavaScript Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
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.
"Mike McCollister" <MikeMcCollister_DELETEME_.DeleteThis@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
>
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum