Results 1 to 12 of 12

Thread: Can I call a function on a parent page?

  1. #1

    Thread Starter
    Addicted Member wernerh's Avatar
    Join Date
    Sep 2000
    Posts
    170

    Question

    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???

  2. #2
    Guest

    Cool

    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,
    Mac

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Im no expert on this stuff, but what if you used the name of the frame in the call ?
    Eg :

    Code:
    <SCRIPT LANGUAGE="VBScript">
    'Some sub ...
    	Frame1.function(param1, param2 ...)
    'End Sub
    </script>
    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554

    I have the same problem...

    Hi I want to know the same thing

    see this post for more info

    http://forums.vb-world.net/showthrea...threadid=54962

    DocZaf
    {;->

  5. #5
    Addicted Member
    Join Date
    Sep 2000
    Posts
    219
    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>
    Last edited by Shafee; Feb 18th, 2001 at 09:40 PM.

  6. #6
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    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
    {;->

  7. #7
    Addicted Member
    Join Date
    Sep 2000
    Posts
    219
    Then I think you can do this:

    Code:
    Window.Navigate "http://test/myasp.asp"

  8. #8
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    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
    {;->

  9. #9
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    By about 3 miles I suspect.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  10. #10
    Addicted Member
    Join Date
    Sep 2000
    Posts
    219
    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.

  11. #11
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    in answer to the original question:

    parent.htm
    Code:
    <HTML>
    <HEAD>
    <Script language=javascript>
    function f(x)
    {
    alert(x)
    
    }
    </script>
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    
    <iframe src='child.htm'>
    </iframe>
    </BODY>
    </HTML>
    child.htm
    Code:
    <HTML>
    <HEAD>
    
    </HEAD>
    <BODY>
    <form>
    <input type=button onclick='parent.f("hello from child.htm")'>
    </form>
    
    </BODY>
    </HTML>
    Mark
    -------------------

  12. #12
    New Member
    Join Date
    Feb 2001
    Location
    Amman-Jordan
    Posts
    1

    Cool

    all what you have to do is:

    <Script language = "VBScript">
    Window.Parent.Frames("Top").FunctionName()
    </script>
    Mohammed Abu Hadhoud

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width