Changing frame location

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sake
    New Member
    • Jan 2007
    • 46

    Changing frame location

    I have a script running in a frame. This script needs to be able to redirect the browser to an entirely different location. However, with the header("locatio n: ") method, only that frame's source is changed. How would I redirect the browser away from those frames?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Use a JavaScript function and issue
    Code:
    top.frames['thatframe'].location.href = 'yourpage.htm';
    where 'thatframe' is the name of the frame you want it to be redirected.

    Ronald

    Comment

    • sake
      New Member
      • Jan 2007
      • 46

      #3
      Originally posted by ronverdonk
      Use a JavaScript function and issue
      Code:
      top.frames['thatframe'].location.href = 'yourpage.htm';
      where 'thatframe' is the name of the frame you want it to be redirected.

      Ronald
      Ok, but this is conditional based on some PHP variable. How do i get it only to issue that command when that PHP if statement passes?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Show your php code that does the redirect. And enclose it within code tags.

        Ronald

        Comment

        • sake
          New Member
          • Jan 2007
          • 46

          #5
          Well its pretty simple. So far its just
          [php]
          if($myVar==$tar get){
          header("Locatio n: http://my.server.com") ;
          }
          [/php]
          But this code is running in a frame, so the redirection only applies to that frame's source, instead of the browser itself.

          Hope that makes sense...

          Comment

          • sake
            New Member
            • Jan 2007
            • 46

            #6
            Kinda stuck here :(
            Any suggestions?

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              Have you tried this one:[php]<?php
              if($myVar==$tar get){
              ?>
              <script>
              top.frames['thatframe'].location.href = 'yourpage.php';
              </script>
              <?php
              exit;
              }
              ?>[/php]Ronald

              Comment

              • sake
                New Member
                • Jan 2007
                • 46

                #8
                Thanks alot for you help :) I had no idea you could mix the two languages like that. Works like a charm

                Comment

                • ronverdonk
                  Recognized Expert Specialist
                  • Jul 2006
                  • 4259

                  #9
                  Yes you can mix.Glad it is solved. See you again next time.

                  Ronald

                  Comment

                  Working...