SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Frames and Javascript

    Hi

    Ill try and explain what im trying to do , im curently using a free script called Cool JS Tree which is nice and simple enough for what we need ..

    What i am trying to do is call the menu which is in one frame from another frame

    Example

    Next button ...goes to another page but also changes the state of the menu on another frame ...

    Code for the button is this ...

    <a href="javascript:void(tree1.collapseAll(true), tree1.selectNode(3), tree1.expandNode(0))">Toggle 'test'</a>

    - tree 1 is the variable on another page how do i call it from the button which is on another page ??

    Hope this makes sense

    G

  2. #2
    SitePoint Enthusiast rash's Avatar
    Join Date
    Dec 2004
    Location
    Earth
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can navigate through frames by
    HTML Code:
    parent.framename.jsfucntion();
    parent = go from current frame to frameset (up one level).
    framename = name of the frame where your function i located.
    jsfucntion() = your function that you want to execute.
    RASH.

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I tried that code but i dont think I have done it right ..the menu lives in a folder away from all the other pages does that matter ? this is the code i have and the error i get is
    EXPECTED IDENTIFIER

    <a href="javascript : parent.../../../../nav_menu/menu_main.php.jsfunction(tree1.collapseAll(true), tree1.selectNode(3), tree1.expandNode(0))"

    Thanks
    G

  5. #5
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone help ?

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are refering to a frameset application

    top.*framename*.jsfunction();

    is all that is required.

    *framename* is the name, not the url, of the target frame
    jsfunction is your function name.

    restriction is that the src of *framename* must be in the same domain

    Did you look at the example I suggested?
    I would have hoped that would have demonstrated the technique.

    or are you refering to iframes?

  7. #7
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The frame im referring to is in another location hence i tried using the URL to see if it picked it up .

    The button im trying to get working needs to do two things

    - when clicked go to another page and also make the menu highlight the page the user is on

    ---- Click Next to go to training page.....training page opens up and the menu on the training page highlights that the user in on the training page..if you catch my drift

    The menu page is just one page and all other framsets point to it so all web pages have the same menu ...the buttons are on a seperate frame so i can see where your coming from where the menu has to be in the same domain as the frame set but this is not the case.

    Surely there is a way of getting the script to do what is needed

    Cheers
    G

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    restriction is that the src of *framename* must be in the same domain
    Surely there is a way of getting the script to do what is needed
    this is a security issue therefore NO

  9. #9
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your wrong ...i have seen this done else where justc ant remember the code

    every web page has its own folder so does the menu so surely there is a way of getting the frame to talk to that other page

    Im not trying to access any other site or domain just another page in another folder in the same domain its all local

  10. #10
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If url is in the same domain you can access it!
    if url is not you can not access it!


    just follow the previous instructions.

    Do NOT specify the url
    Specify the frame name as specified in the frameset

  11. #11
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="javascript: parent.testtop.COOLjsTreePRO(tree1.collapseAll(true), tree1.selectNode(3), tree1.expandNode(0))">Toggle 'test'</a>

    comes back with parent.testtop is null or not an object and all pages are uploaded on the test server

    SOrry for the trouble

  12. #12
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="javascript:top.testtop.COOLjsTreePRO(tree1.collapseAll(true), tree1.selectNode(3), tree1.expandNode(0))">Toggle 'test'</a>

    altered some stuff and now I get tree1 is undefined which i cant understand

    the testtop page

    contains

    <html>
    <head>
    <title>testtop</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="../nav_menu/tree_styles.css" rel="stylesheet" type="text/css">
    <script language="JavaScript" src="../nav_menu/cooltreepro.js"></script>
    <script language="JavaScript" src="../nav_menu/tree_format.js"></script>
    <script language="JavaScript" src="../nav_menu/tree_nodes.js"></script>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <script>
    var tree1 = new COOLjsTreePRO("tree1", TREE_NODES, TREE_FORMAT);
    tree1.init();
    </script>
    <script type="text/javascript">RedrawAllTrees()
    </script>

    </body>
    </html>

    so i cant understand why tree 1 is reported as undefined

  13. #13
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FrameSet

    PHP Code:
    <html>
    <
    head>
    <
    title>You need a browser that supports frame to veiw this page.</title>
    <
    meta name="description" content="Divides the page vertically in two frames.">
    </
    head>
    <
    frameset rows="1*" cols="50%, 50%">
    <
    frame name="testtop" scrolling="auto" marginwidth="10" marginheight="14" src="LF.htm">
    <
    frame name="right" scrolling="auto" marginwidth="10" marginheight="14" src="RF.htm">
    <
    noframes>
    <
    body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

    <
    p>You need a browser that supports frame to veiw this page.</p>
    </
    body>
    </
    noframes>
    </
    frameset>
    </
    html
    LH Frame LF.htm

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    COOLjsTreePRO(a,b,c){
     
    alert('function attribute 0 = '+a);
     
    alert('function attribute 1 = '+b);
     
    alert('function attribute 2 = '+c);
    }
    //-->
    </script></head>

    <body>
    LFrame
    </body>

    </html> 
    RH Frame RF.htm

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    </
    head>

    <
    body>
    RFrame
    <a href="javascript:top.testtop.COOLjsTreePRO('tom','dick','harry')">Toggle 'test'</a>

    </
    body>

    </
    html
    I previously posted you a link to an example

    and now I post a simpler example to demonstrate the use of TOP and receipt of call attributes in frameset applications.

    I have not looked at the menu you are using and do not wish to be involved in yet another menu at the moment but suggest you call a new function to execise the menu as you would on if it was on an unframed page then work back from there.

    or better still, get a menu that is well documented, supported and you can fully understand the functionality and application.

  14. #14
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I studied your page / website and found no reference on how to influence a menu from a frame page . Your code displays a menu on another frame which i understand ..but i didnt see how to influence the menu from another page ! unless im missing the obvious

    The support team who do this menu are more than useless and never respond to any emails

    Ill keep working on this

    thanks


Bookmarks

Posting Permissions

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