A little help with PHP and frames appreciated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nick_m37
    New Member
    • Jun 2006
    • 2

    #1

    A little help with PHP and frames appreciated

    I am haveing problems trying to get access to another frame from a frame that runs php. The code is as follows essentially;

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>set</title>
    </head>
    <frameset rows="50%,50%">
    <frame name="upper" src="upper.html ">
    <frame name="lower" src="http://localhost/test/lower.php">
    </frameset>"
    </html>

    //upper.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>upper</title>
    </head>
    <body>
    <P>upper</p>
    </body>
    </html>

    //lower.php
    <html>
    <head>
    <title>lower</title>
    </head>
    <body>
    <?php
    print("lower<br >\n");
    print("<script language=\"Java Script\">\n");
    print("document .write(parent.f rames.length);\ n");
    print("parent.f rames[\"upper\"].document.open( );\n");
    print("parent.f rames[\"upper\"].document.write ln(\"test2\");\ n");
    print("parent.f rames[\"upper\"].document.close ();\n");
    print("</script>\n");
    ?>
    </body>
    </html>

    Is there anyone that can tell me what I am doing wrong and if there is anything extra you have to do to be able to get a php file to access another frame under the same parent as this setup is getting denied access errors from the lower.php file part.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Originally posted by nick_m37
    //lower.php
    <html>
    <head>
    <title>lower</title>
    </head>
    <body>
    <?php
    print("lower<br >\n");
    print("<script language=\"Java Script\">\n");
    print("document .write(parent.f rames.length);\ n");
    print("parent.f rames[\"upper\"].document.open( );\n");
    print("parent.f rames[\"upper\"].document.write ln(\"test2\");\ n");
    print("parent.f rames[\"upper\"].document.close ();\n");
    print("</script>\n");
    ?>
    </body>
    </html>
    I don't think it's anything to do with php I don't think that you can re-open a document once it is loaded an write to it like that. You have to create a new document, also you are calling open with the wrong parameters.

    try

    [php]
    <?php
    print("lower<br >\n");
    print("<script language=\"Java Script\">\n");
    print("document .write(parent.f rames.length);\ n");
    print("var newDoc=parent.f rames[\"upper\"].document.open( \"text/html\", \"replace\");\n ");
    print("newDoc.w riteln(\"test2\ ");\n");
    print("newDoc.d ocument.close() ;\n");
    print("</script>\n");
    ?>
    [/php]

    See http://www.w3schools.com/htmldom/met_doc_open.asp

    and

    The W3Schools online code editor allows you to edit code and view the result in your browser


    oh and this is a whole lot easier to read as

    [php]
    <?php
    print <<<JSWRITE
    lower<br>
    <script language="JavaS cript">
    document.write( parent.frames.l ength);
    var newDoc=parent.f rames["upper"].document.open( "text/html", "replace");
    newDoc.writeln( "test2");
    newDoc.document .close();
    </script>
    JSWRITE;
    ?>
    [/php]

    Comment

    • nick_m37
      New Member
      • Jun 2006
      • 2

      #3
      Same problem revisited

      I tried that but still got the access denied problem as before with the javascript declaration line in lower.php. Is there any reason that php scripts would not be able to access the other frame?

      Comment

      • goodmorningegg
        New Member
        • Jun 2006
        • 5

        #4
        I dont know if you want to rebuild your entire site, but I built one of my sites with the look of frames using php. Here is the site that helped me build it.


        It should hopefully fix your problem

        Comment

        Working...