By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

Know page that fired an event

P: n/a
How do i identify the page that fired a method?

e.g.
page1.html
-----------
<Head>
<script>
document.write(myfun());
</script>

Assume that page1.html is in a frame (or iframe) in page.aspx. page.aspx
contains an include file say, myinc.js. myfun() is inside myinc.js. How do i
come to know that myfun() was fired from page1.html?
--
sunil philip,
S/W Engineer
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Access frame from parent script

frame2.document.write("a message"); //any object can be called from frame2,
not just document.write

Access one frame from another
parent.frame2.document.write("Hi frame2");

Hope this helps.
Regards,
Jignesh Desai
www.dotnetjini.com
"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
How do i identify the page that fired a method?

e.g.
page1.html
-----------
<Head>
<script>
document.write(myfun());
</script>

Assume that page1.html is in a frame (or iframe) in page.aspx. page.aspx
contains an include file say, myinc.js. myfun() is inside myinc.js. How do i come to know that myfun() was fired from page1.html?
--
sunil philip,
S/W Engineer

Nov 19 '05 #2

P: n/a
Let me put it the other way round.
I am invoking myfun() from page1.html. I need to get the id of page1.html
(without using 'this').

"Jignesh Desai" wrote:
Access frame from parent script

frame2.document.write("a message"); //any object can be called from frame2,
not just document.write

Access one frame from another
parent.frame2.document.write("Hi frame2");

Hope this helps.
Regards,
Jignesh Desai
www.dotnetjini.com
"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
How do i identify the page that fired a method?

e.g.
page1.html
-----------
<Head>
<script>
document.write(myfun());
</script>

Assume that page1.html is in a frame (or iframe) in page.aspx. page.aspx
contains an include file say, myinc.js. myfun() is inside myinc.js. How do

i
come to know that myfun() was fired from page1.html?
--
sunil philip,
S/W Engineer


Nov 19 '05 #3

P: n/a
If myfunc is triggered from an event, say a button click, you could look at
the event.srcElement control. If the button click caused myFunc to fire,
the button will be the srcElement. You then could determine the form, or
the containing control by stepping up the parent attribute of the control.

HTH,

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Let me put it the other way round.
I am invoking myfun() from page1.html. I need to get the id of page1.html
(without using 'this').

"Jignesh Desai" wrote:
Access frame from parent script

frame2.document.write("a message"); //any object can be called from frame2, not just document.write

Access one frame from another
parent.frame2.document.write("Hi frame2");

Hope this helps.
Regards,
Jignesh Desai
www.dotnetjini.com
"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
How do i identify the page that fired a method?

e.g.
page1.html
-----------
<Head>
<script>
document.write(myfun());
</script>

Assume that page1.html is in a frame (or iframe) in page.aspx. page.aspx contains an include file say, myinc.js. myfun() is inside myinc.js.
How do i
come to know that myfun() was fired from page1.html?
--
sunil philip,
S/W Engineer


Nov 19 '05 #4

P: n/a
Thats my main problem. I am not firing the function from any event.I am
firing it from document.write.Any workaround for this??
"William F. Robertson, Jr." wrote:
If myfunc is triggered from an event, say a button click, you could look at
the event.srcElement control. If the button click caused myFunc to fire,
the button will be the srcElement. You then could determine the form, or
the containing control by stepping up the parent attribute of the control.

HTH,

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Let me put it the other way round.
I am invoking myfun() from page1.html. I need to get the id of page1.html
(without using 'this').

"Jignesh Desai" wrote:
Access frame from parent script

frame2.document.write("a message"); //any object can be called from frame2, not just document.write

Access one frame from another
parent.frame2.document.write("Hi frame2");

Hope this helps.
Regards,
Jignesh Desai
www.dotnetjini.com
"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
> How do i identify the page that fired a method?
>
> e.g.
> page1.html
> -----------
> <Head>
> <script>
> document.write(myfun());
> </script>
>
> Assume that page1.html is in a frame (or iframe) in page.aspx. page.aspx > contains an include file say, myinc.js. myfun() is inside myinc.js. How do i
> come to know that myfun() was fired from page1.html?
>
>
> --
> sunil philip,
> S/W Engineer


Nov 19 '05 #5

P: n/a
If your function is sitting in some global repository and is included into
page1.html, you can determine the scope the function is executing in with
the document.location.href for the full url to the page, or
document.location.pathname to get "/page1.html".

I tried using your document.write method but could not get the function to
fire properly, so I gave up on it, but the document.location will return the
scope the function is currently executing on.

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
Thats my main problem. I am not firing the function from any event.I am
firing it from document.write.Any workaround for this??
"William F. Robertson, Jr." wrote:
If myfunc is triggered from an event, say a button click, you could look at the event.srcElement control. If the button click caused myFunc to fire, the button will be the srcElement. You then could determine the form, or the containing control by stepping up the parent attribute of the control.
HTH,

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Let me put it the other way round.
I am invoking myfun() from page1.html. I need to get the id of page1.html (without using 'this').

"Jignesh Desai" wrote:

> Access frame from parent script
>
> frame2.document.write("a message"); //any object can be called from

frame2,
> not just document.write
>
> Access one frame from another
> parent.frame2.document.write("Hi frame2");
>
> Hope this helps.
> Regards,
> Jignesh Desai
> www.dotnetjini.com
>
>
> "sunil philip" <su*********@discussions.microsoft.com> wrote in message > news:CA**********************************@microsof t.com...
> > How do i identify the page that fired a method?
> >
> > e.g.
> > page1.html
> > -----------
> > <Head>
> > <script>
> > document.write(myfun());
> > </script>
> >
> > Assume that page1.html is in a frame (or iframe) in page.aspx.

page.aspx
> > contains an include file say, myinc.js. myfun() is inside
myinc.js. How do
> i
> > come to know that myfun() was fired from page1.html?
> >
> >
> > --
> > sunil philip,
> > S/W Engineer
>
>
>


Nov 19 '05 #6

P: n/a
Ya, my function is sitting in global repository. The structure is something
like this

page1.aspx
------------
<script language="javascript" src="myGlobalFile.js"></script>
<frameset >
<frame name="header" src='Header.aspx' >
<frameset >
<frame id="contents">
<frame name="main" src='myPage.aspx' id="main">
</frameset>
</frameset>

myPage.aspx
---------------

<script>
document.write(top.funInmyGlobalFile());
</script>

<Iframe>
<frameset src = "page1.html">
</Iframe>

Now, page1.html contains the same
<script>
document.write(top.funInmyGlobalFile());
</script>

document.location.href will not give me Page1.html. It will only give me
page1.aspx when iam calling funInmyGlobalFile() from page1.html.
I want to identify thet funInmyGlobalFile() is fired from page1.html.
I hope u got a clear picture about my problem.
Sorry for keeping u in air.

Thanks

"William F. Robertson, Jr." wrote:
If your function is sitting in some global repository and is included into
page1.html, you can determine the scope the function is executing in with
the document.location.href for the full url to the page, or
document.location.pathname to get "/page1.html".

I tried using your document.write method but could not get the function to
fire properly, so I gave up on it, but the document.location will return the
scope the function is currently executing on.

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
Thats my main problem. I am not firing the function from any event.I am
firing it from document.write.Any workaround for this??
"William F. Robertson, Jr." wrote:
If myfunc is triggered from an event, say a button click, you could look at the event.srcElement control. If the button click caused myFunc to fire, the button will be the srcElement. You then could determine the form, or the containing control by stepping up the parent attribute of the control.
HTH,

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
> Let me put it the other way round.
> I am invoking myfun() from page1.html. I need to get the id of page1.html > (without using 'this').
>
> "Jignesh Desai" wrote:
>
> > Access frame from parent script
> >
> > frame2.document.write("a message"); //any object can be called from
frame2,
> > not just document.write
> >
> > Access one frame from another
> > parent.frame2.document.write("Hi frame2");
> >
> > Hope this helps.
> > Regards,
> > Jignesh Desai
> > www.dotnetjini.com
> >
> >
> > "sunil philip" <su*********@discussions.microsoft.com> wrote in message > > news:CA**********************************@microsof t.com...
> > > How do i identify the page that fired a method?
> > >
> > > e.g.
> > > page1.html
> > > -----------
> > > <Head>
> > > <script>
> > > document.write(myfun());
> > > </script>
> > >
> > > Assume that page1.html is in a frame (or iframe) in page.aspx.
page.aspx
> > > contains an include file say, myinc.js. myfun() is inside myinc.js. How do
> > i
> > > come to know that myfun() was fired from page1.html?
> > >
> > >
> > > --
> > > sunil philip,
> > > S/W Engineer
> >
> >
> >


Nov 19 '05 #7

P: n/a
I have tried and looked long and hard to find this solution. It appears the
only way to accomplish this is to add "this" as a parameter to your
funinmyGlobalFile function.

With the this parameter, you can pull the proper location.href to get the
html page of the caller.

I know this isn't quite the solution you were looking for, but this (pun) is
the best I could come up with.

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:F2**********************************@microsof t.com...
Ya, my function is sitting in global repository. The structure is something like this

page1.aspx
------------
<script language="javascript" src="myGlobalFile.js"></script>
<frameset >
<frame name="header" src='Header.aspx' >
<frameset >
<frame id="contents">
<frame name="main" src='myPage.aspx' id="main">
</frameset>
</frameset>

myPage.aspx
---------------

<script>
document.write(top.funInmyGlobalFile());
</script>

<Iframe>
<frameset src = "page1.html">
</Iframe>

Now, page1.html contains the same
<script>
document.write(top.funInmyGlobalFile());
</script>

document.location.href will not give me Page1.html. It will only give me
page1.aspx when iam calling funInmyGlobalFile() from page1.html.
I want to identify thet funInmyGlobalFile() is fired from page1.html.
I hope u got a clear picture about my problem.
Sorry for keeping u in air.

Thanks

"William F. Robertson, Jr." wrote:
If your function is sitting in some global repository and is included into page1.html, you can determine the scope the function is executing in with the document.location.href for the full url to the page, or
document.location.pathname to get "/page1.html".

I tried using your document.write method but could not get the function to fire properly, so I gave up on it, but the document.location will return the scope the function is currently executing on.

bill

"sunil philip" <su*********@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
Thats my main problem. I am not firing the function from any event.I am firing it from document.write.Any workaround for this??
"William F. Robertson, Jr." wrote:

> If myfunc is triggered from an event, say a button click, you could look
at
> the event.srcElement control. If the button click caused myFunc to

fire,
> the button will be the srcElement. You then could determine the
form, or
> the containing control by stepping up the parent attribute of the

control.
>
> HTH,
>
> bill
>
> "sunil philip" <su*********@discussions.microsoft.com> wrote in

message > news:0A**********************************@microsof t.com...
> > Let me put it the other way round.
> > I am invoking myfun() from page1.html. I need to get the id of

page1.html
> > (without using 'this').
> >
> > "Jignesh Desai" wrote:
> >
> > > Access frame from parent script
> > >
> > > frame2.document.write("a message"); //any object can be called from > frame2,
> > > not just document.write
> > >
> > > Access one frame from another
> > > parent.frame2.document.write("Hi frame2");
> > >
> > > Hope this helps.
> > > Regards,
> > > Jignesh Desai
> > > www.dotnetjini.com
> > >
> > >
> > > "sunil philip" <su*********@discussions.microsoft.com> wrote in

message
> > > news:CA**********************************@microsof t.com...
> > > > How do i identify the page that fired a method?
> > > >
> > > > e.g.
> > > > page1.html
> > > > -----------
> > > > <Head>
> > > > <script>
> > > > document.write(myfun());
> > > > </script>
> > > >
> > > > Assume that page1.html is in a frame (or iframe) in page.aspx.
> page.aspx
> > > > contains an include file say, myinc.js. myfun() is inside

myinc.js.
> How do
> > > i
> > > > come to know that myfun() was fired from page1.html?
> > > >
> > > >
> > > > --
> > > > sunil philip,
> > > > S/W Engineer
> > >
> > >
> > >
>
>
>


Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.