specifying a new window when using Location:

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mantrid

    specifying a new window when using Location:

    In some of my script ive been using the followin

    if(isset($_POST['mybutton'])){
    header("Locatio n: http://www.mysite.co.u k/path/my.php");
    }


    This changes the page in the open browser window. How can I modify this to
    open a new window without replacing the parent


  • Oli Filth

    #2
    Re: specifying a new window when using Location:

    mantrid said the following on 26/09/2006 23:59:
    In some of my script ive been using the followin
    >
    if(isset($_POST['mybutton'])){
    header("Locatio n: http://www.mysite.co.u k/path/my.php");
    }
    >
    >
    This changes the page in the open browser window. How can I modify this to
    open a new window without replacing the parent
    You can't. HTTP headers don't work that way.

    The only way to achieve this behaviour is to include HTML/JavaScript
    code which causes a new window to automatically appear. But note that
    that's exactly what a pop-up is, and most browsers have pop-up blockers
    nowadays, because people don't like them...


    --
    Oli

    Comment

    • Johnny

      #3
      Re: specifying a new window when using Location:


      "mantrid" <ian.dandav@vir gin.netwrote in message
      news:DhiSg.4223 0$wo3.37618@new sfe7-gui.ntli.net...
      In some of my script ive been using the followin
      >
      if(isset($_POST['mybutton'])){
      header("Locatio n: http://www.mysite.co.u k/path/my.php");
      }
      >
      >
      This changes the page in the open browser window. How can I modify this to
      open a new window without replacing the parent
      >
      >
      this works:

      if(isset($_POST['mybutton'])){
      echo <<<WIND
      <script type="text/javascript">
      window.open("ht tp://www.mysite.co.u k/path/my.php");
      </script>
      WIND;
      }

      but as you can se also requires js


      Comment

      • mantrid

        #4
        Re: specifying a new window when using Location:

        Thanks Johnny
        That works but not if popups are blocked
        So I was wondering if there is a way of testing if popup blocking is set and
        if not run the first bit of code and if so run the second so at least the
        user would get the page even if it is not on a separate window ie something
        like;


        if(isset($_POST['viewtest'])){ ?>

        if popup blocking is not set then run the following

        <script type="text/javascript">
        window.open("ht tp://www.mysite.co.u k/path/mypage.php");
        </script>
        <?php

        else if popup blocking is set run the following

        header("Locatio n: http://www.mysite.co.u k/path/mypage.php");

        }



        "Johnny" <removethis.huu anito@hotmail.c omwrote in message
        news:OKmSg.406$ UJ2.198@fed1rea d07...
        >
        "mantrid" <ian.dandav@vir gin.netwrote in message
        news:DhiSg.4223 0$wo3.37618@new sfe7-gui.ntli.net...
        In some of my script ive been using the followin

        if(isset($_POST['mybutton'])){
        header("Locatio n: http://www.mysite.co.u k/path/my.php");
        }


        This changes the page in the open browser window. How can I modify this
        to
        open a new window without replacing the parent
        this works:
        >
        if(isset($_POST['mybutton'])){
        echo <<<WIND
        <script type="text/javascript">
        window.open("ht tp://www.mysite.co.u k/path/my.php");
        </script>
        WIND;
        }
        >
        but as you can se also requires js
        >
        >

        Comment

        • Colin Fine

          #5
          Re: specifying a new window when using Location:

          mantrid wrote:
          Thanks Johnny
          That works but not if popups are blocked
          So I was wondering if there is a way of testing if popup blocking is set and
          if not run the first bit of code and if so run the second so at least the
          user would get the page even if it is not on a separate window ie something
          like;
          >
          >
          if(isset($_POST['viewtest'])){ ?>
          >
          if popup blocking is not set then run the following
          >
          <script type="text/javascript">
          window.open("ht tp://www.mysite.co.u k/path/mypage.php");
          </script>
          <?php
          >
          else if popup blocking is set run the following
          >
          header("Locatio n: http://www.mysite.co.u k/path/mypage.php");
          >
          }
          >
          >
          >
          "Johnny" <removethis.huu anito@hotmail.c omwrote in message
          news:OKmSg.406$ UJ2.198@fed1rea d07...
          >"mantrid" <ian.dandav@vir gin.netwrote in message
          >news:DhiSg.422 30$wo3.37618@ne wsfe7-gui.ntli.net...
          >>In some of my script ive been using the followin
          >>>
          >>if(isset($_PO ST['mybutton'])){
          >> header("Locatio n: http://www.mysite.co.u k/path/my.php");
          >>}
          >>>
          >>>
          >>This changes the page in the open browser window. How can I modify this
          to
          >>open a new window without replacing the parent
          >>>
          >>>
          >this works:
          >>
          >if(isset($_POS T['mybutton'])){
          >echo <<<WIND
          > <script type="text/javascript">
          > window.open("ht tp://www.mysite.co.u k/path/my.php");
          > </script>
          >WIND;
          >}
          >>
          >but as you can se also requires js
          >>
          >>
          >
          >
          If there is a way, it is probably browser-dependent; and I'm not sure
          there is.

          But I would think that you could make the javascript try and create the
          window with a name, and then check whether the named window exists. If
          not, you can change 'location' in the Js.

          Colin

          Comment

          Working...