PHP & Javascript new window forces main page to load blank screen

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

    PHP & Javascript new window forces main page to load blank screen

    I have a problem with a call a Javascript "window.ope n()" function which is
    executed as part of a PHP file when a user clicks on an thumbnail image.
    The PHP is executed which passes some variables to Javascript to execute
    the new window opening. But as it does this, the main window is loaded
    which is blank (the browser URL bar shows the URL of the URL passed to the
    PHP / Javascript script).

    I would like to keep the gallery page visible in the main page which is
    where the link originally came from, so the user can see the gallery
    underneath the "popup" window of the called graphic.

    I don't know how much of an added problem it is, but the script that
    generates the whole sites pages is in the root directory, and the gallery
    HTML is in some seperate sub-directory and is "included" into the page
    layout (using variables passed on a page click).

    Any help appreciated.

    Dariusz


    Gallery script calling the PHP file to execute on image thumbnail click:

    <a href="php/pics.php?&gal=c oll01&picID=01" ><img
    src="img/gallery1/s-dg01.jpg" ALT="Picture 1" width="30"
    height="69"></A>
    <a href="php/pics.php?&gal=c oll01&picID=02" ><img
    src="img/gallery1/s-dg02.jpg" ALT="Picture 2" width="74"
    height="69"></A>

    This passes the variables to the other PHP script which picture to grab.


    PHP file with the Javascript (pics.php):

    <?PHP
    // Section to generate the Javascript pop-up for correct
    // dimentions of the proposed pop-up.

    $URL = '..img/gallery1/dg'.$_GET['picID'].'.jpg';

    print "<script type=\"text/javascript\">
    <!--

    var Jurl=\"$URL\";
    ";

    ?>

    window.
    open(Jurl,"Pict ure","width=370 ,height=260,too lbar=no,menubar =no,
    resizeable=no") ;

    //-->
    </script>
  • jn

    #2
    Re: PHP &amp; Javascript new window forces main page to load blank screen

    "Dariusz" <ng@lycaus.plus YOURSHIT.com> wrote in message
    news:1_Lic.3638 0$Y%6.4819587@w ards.force9.net ...[color=blue]
    > I have a problem with a call a Javascript "window.ope n()" function which[/color]
    is[color=blue]
    > executed as part of a PHP file when a user clicks on an thumbnail image.
    > The PHP is executed which passes some variables to Javascript to execute
    > the new window opening. But as it does this, the main window is loaded
    > which is blank (the browser URL bar shows the URL of the URL passed to the
    > PHP / Javascript script).
    >
    > I would like to keep the gallery page visible in the main page which is
    > where the link originally came from, so the user can see the gallery
    > underneath the "popup" window of the called graphic.
    >
    > I don't know how much of an added problem it is, but the script that
    > generates the whole sites pages is in the root directory, and the gallery
    > HTML is in some seperate sub-directory and is "included" into the page
    > layout (using variables passed on a page click).
    >
    > Any help appreciated.
    >
    > Dariusz
    >
    >
    > Gallery script calling the PHP file to execute on image thumbnail click:
    >
    > <a href="php/pics.php?&gal=c oll01&picID=01" ><img
    > src="img/gallery1/s-dg01.jpg" ALT="Picture 1" width="30"
    > height="69"></A>
    > <a href="php/pics.php?&gal=c oll01&picID=02" ><img
    > src="img/gallery1/s-dg02.jpg" ALT="Picture 2" width="74"
    > height="69"></A>
    >
    > This passes the variables to the other PHP script which picture to grab.
    >
    >
    > PHP file with the Javascript (pics.php):
    >
    > <?PHP
    > // Section to generate the Javascript pop-up for correct
    > // dimentions of the proposed pop-up.
    >
    > $URL = '..img/gallery1/dg'.$_GET['picID'].'.jpg';
    >
    > print "<script type=\"text/javascript\">
    > <!--
    >
    > var Jurl=\"$URL\";
    > ";
    >
    > ?>
    >
    > window.
    > open(Jurl,"Pict ure","width=370 ,height=260,too lbar=no,menubar =no,
    > resizeable=no") ;
    >
    > //-->
    > </script>
    >[/color]

    This seems a strange way to do it.

    On your thumbnail page, include a function to open a window using a url
    passed to it.

    (this script is untested, but you get the idea)

    <script>
    function open(url){
    window.open(url ,"Picture","wid th=370,height=2 60,toolbar=no,m enubar=no,resiz e
    able=no");
    }
    </script>

    Inside your thumbnail links, just call your function with the correct url:

    <a href="#" onclick="open(' ..img/gallery1/1.jpg')">

    That way, you don't need to load a separate page in the main window just to
    open.


    Comment

    • Milos Vucic

      #3
      Re: PHP &amp; Javascript new window forces main page to load blank screen


      "jn" <usenet*spamist ehsuckremovetor eply*@jasonnorr is.net> wrote in message
      news:d_Vic.7509 9$I83.1754097@t wister.tampabay .rr.com...
      [color=blue]
      > <script>
      > function open(url){
      >[/color]
      window.open(url ,"Picture","wid th=370,height=2 60,toolbar=no,m enubar=no,resiz e[color=blue]
      > able=no");
      > }
      > </script>
      >
      > Inside your thumbnail links, just call your function with the correct url:
      >
      > <a href="#" onclick="open(' ..img/gallery1/1.jpg')">[/color]

      If you have to scroll down to see the thumbnail you want to
      "enlarge", your way would open a new window and because
      of this # it would cause browser to move "focus" to the top
      of the main page, so for next image, we would have to scroll
      down again to see thumbnails, etc...
      Another thing, if somebody tries to open that link in a new
      window, 2 windows will be open, one for the image, and
      another for the main page.


      Comment

      Working...