Hi folks,
Is there anyway to redirect a page in a frame to target=_top

header("Location: logout.php");

I am using this inside a frame but i need the logout page to be on top.Does anybody know how to do it

    Some client-side scripting is all I can think of:

    <script type="text/javascript">
    top.window.location = 'logout.php';
    </script>

      Put this, or something like it, in your HTML where you want the focus to be

      <a name="TOP">FOCUS HERE</a>

      Then change your location to

      header("Location: logout.php/#TOP");
        rincewind456 wrote:
        header("Location: logout.php/#TOP");

        First, why is there a "/" ?! It will give something like this :
        http://localhost/logout.php/#TOP

        logout.php is a file, not a directory !

        Second, URLs should be absolute ([url]http://.[/url]....) and not relative 😉

        header(sprintf(('Location: http://%s%s%s' . "\n"), $_SERVER['HTTP_HOST'], (dirname($_SERVER['SCRIPT_NAME']) . '/'), 'logout.php#TOP'));
          suntra wrote:

          First, why is there a "/" ?! It will give something like this :
          http://localhost/logout.php/#TOP

          logout.php is a file, not a directory !

          Second, URLs should be absolute ([url]http://.[/url]....) and not relative 😉

          header(sprintf(('Location: http://%s%s%s' . "\n"), $_SERVER['HTTP_HOST'], (dirname($_SERVER['SCRIPT_NAME']) . '/'), 'logout.php#TOP'));

          Before you started wittering on, did you try it?

          The / isn't essental

          header("Location: logout.php#TOP");

          will work just fine as well.

          And URI's do not have to be absolute.

            rincewind456 wrote:

            And URI's do not have to be absolute.

            For some, a 'requirement' means meeting established guidelines or regulations. In that case, yes, a full URI is required. For others, a 'requirement' is simply doing something good enough to get by with.

            Either way, is this really what the original poster wanted? I believe they were looking at how to redirect the top-most frame to a different location... not just move to the top of the current page.

              Either way, is this really what the original poster wanted? I believe they were looking at how to redirect the top-most frame to a different location... not just move to the top of the current page.

              And that is exactly what it does. It will go to a page called login.php that is in the same directory and it will go to the area marked with the HTML anchor tag, be that at the top, middle or bottom of the page.

                Right... but you see, "top" has nothing to do with position, a named anchor, or anything of that nature. Since the original poster talked about "target=top", I believe he meant he wants to change the location of the outer- (or top-) most frameset.

                For an example, click here.

                  I'm sorry but have you actually tested the code I posted?

                  And target=top is fully described here.

                  I have offered a way to do what I believe the OP wanted without the use of javascript.

                    HTTP redirects are a way of saying that the object has moved to another location, i.e. can be found elsewhere.

                    As such, you cannot change the context which it's used in, be it image, frame, etc.

                    In order to do what you're suggesting, you'd need to use client script. Or better still, just change the target of the original link to _top

                    Mark

                      my .02 on relative vs absolute URI's

                      For development purposes I use relative URI's
                      For production purposes I use absolute URI's

                      of course, you could just run a little function that would give you the absolute path of a script regardless of the server it's on, but for some it isn't necessary

                      It's a matter of personal preference and code environment

                        Per the HTTP 1.1 specification for the Location header, the location should be specified as an absolute URI. It seems that most modern clients deal with relative URI's, but if you use one you're depending on the client to deal with a non-standard header. Personally, I therefore always use a full, absolute URI in my Location headers so that if, by any chance, my code gets accessed by a client that doesn't handle a relative URI, it won't be my non-standard-compliant coding that causes a problem.

                          I think the two discussions that have been started here ('_top' and the Location header) have both represented their sides, and that any further discussion would simply be an argument (possibly erupting into a mini flame war). As such, I think we should all wait to hear back from the original poster to clarify questions raised and test suggestions given.

                          If anyone wishes to start a discussion about one of these topics (or any similar topic), feel free to start such a thread in the Echo Lounge.

                            Write a Reply...