| re: PHP & Javascript new window forces main page to load blank screen
"Dariusz" <ng@lycaus.plusYOURSHIT.com> wrote in message
news:1_Lic.36380$Y%6.4819587@wards.force9.net...[color=blue]
> I have a problem with a call a Javascript "window.open()" 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=coll01&picID=01"><img
> src="img/gallery1/s-dg01.jpg" ALT="Picture 1" width="30"
> height="69"></A>
> <a href="php/pics.php?&gal=coll01&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,"Picture","width=370,height=260,toolbar= 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","width=370,height=260,to olbar=no,menubar=no,resize
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. |