Click to See Complete Forum and Search --> : Can I call a function on a parent page?
wernerh
Feb 15th, 2001, 12:01 AM
Is it possible to call a function on a parent page from the child?
I have a page loaded in a IFRAME and I wand to call a function on the parent page?
Can this be done and HOW???
Hi...
i don't think you can call the function parent page from the child page.
But u can include a file using include tag ...whereby ur include file consist of all the function.
Regards,
:o Mac :)
plenderj
Feb 15th, 2001, 06:32 AM
Im no expert on this stuff, but what if you used the name of the frame in the call ?
Eg :
<SCRIPT LANGUAGE="VBScript">
'Some sub ...
Frame1.function(param1, param2 ...)
'End Sub
</script>
- jamie
Zaf Khan
Feb 17th, 2001, 05:35 AM
Hi I want to know the same thing
see this post for more info
http://forums.vb-world.net/showthread.php?s=&threadid=54962
DocZaf
{;->
Shafee
Feb 18th, 2001, 08:26 PM
Here is what you have to do:
<Script language = "VBScript">
Window.Parent.Frames("Top").Test()
</script>
I have tested it. It works.
Why do you want to do this? There is a better way. You can create a .vbs file and use the following in your page:
<script language = "VBScript" src="Functions.vbs">
</script>
<script language = "VBScript">
Test
</script>
Zaf Khan
Feb 18th, 2001, 09:44 PM
I have tested it. It works.
Why do you want to do this? There is a better way. You can create a .vbs file and use the following in your page:
<script language = "VBScript" src="Functions.vbs">
</script>
<script language = "VBScript">
Test
</script>
Okay so that works for htm file what if its an asp file and it needs to be precessed before sending to the clients browser?
DocZaf
{;->
Shafee
Feb 19th, 2001, 08:57 PM
Then I think you can do this:
Window.Navigate "http://test/myasp.asp"
Zaf Khan
Feb 19th, 2001, 09:47 PM
Sorry, I dont think i explained myself properly.
I have code routines wriiten in asp which use to process requests for any documents on the site, and the routines would be applied to say 80% of the documents on the website.
I dont want to duplicate the code in EACH page I would rather pace the code in common document (in this case the frames page) and just execute it along with whatever parameters i pass.
It needs to be in asp as it connects to the access db and i'm not sure if i connect to the db if its in a .vbs file
Also when i did try on my pc, I found that if the page was .htm then the code gets executed and if its asp then it doesn't.
Something is wrong here or maybe i'm missing the point by a mile.
Alas.....
DocZaf
{;->
plenderj
Feb 20th, 2001, 02:20 AM
By about 3 miles I suspect.
Shafee
Feb 20th, 2001, 04:20 AM
I think you can use .vbs files in asp script. Try this:
<script language = "VBScript" Runat="Server" Src="Functions.vbs">
</script>
I think it will work.
Mark Sreeves
Feb 20th, 2001, 08:54 AM
in answer to the original question:
parent.htm
<HTML>
<HEAD>
<Script language=javascript>
function f(x)
{
alert(x)
}
</script>
<TITLE></TITLE>
</HEAD>
<BODY>
<iframe src='child.htm'>
</iframe>
</BODY>
</HTML>
child.htm
<HTML>
<HEAD>
</HEAD>
<BODY>
<form>
<input type=button onclick='parent.f("hello from child.htm")'>
</form>
</BODY>
</HTML>
mSaqer
Feb 25th, 2001, 06:11 AM
all what you have to do is:
<Script language = "VBScript">
Window.Parent.Frames("Top").FunctionName()
</script>
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.