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???
Printable View
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 :)
Im no expert on this stuff, but what if you used the name of the frame in the call ?
Eg :
- jamieCode:<SCRIPT LANGUAGE="VBScript">
'Some sub ...
Frame1.function(param1, param2 ...)
'End Sub
</script>
Hi I want to know the same thing
see this post for more info
http://forums.vb-world.net/showthrea...threadid=54962
DocZaf
{;->
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>
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?Quote:
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>
DocZaf
{;->
Then I think you can do this:
Code:Window.Navigate "http://test/myasp.asp"
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
{;->
By about 3 miles I suspect.
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.
in answer to the original question:
parent.htm
child.htmCode:<HTML>
<HEAD>
<Script language=javascript>
function f(x)
{
alert(x)
}
</script>
<TITLE></TITLE>
</HEAD>
<BODY>
<iframe src='child.htm'>
</iframe>
</BODY>
</HTML>
Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<form>
<input type=button onclick='parent.f("hello from child.htm")'>
</form>
</BODY>
</HTML>
all what you have to do is:
<Script language = "VBScript">
Window.Parent.Frames("Top").FunctionName()
</script>