Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 05:58 AM
Dariusz
Guest
 
Posts: n/a
Default PHP & Javascript new window forces main page to load blank screen

I have a problem with a call a Javascript "window.open()" 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=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>
  #2  
Old July 17th, 2005, 05:58 AM
jn
Guest
 
Posts: n/a
Default 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.


  #3  
Old July 17th, 2005, 06:00 AM
Milos Vucic
Guest
 
Posts: n/a
Default Re: PHP & Javascript new window forces main page to load blank screen


"jn" <usenet*spamistehsuckremovetoreply*@jasonnorris.ne t> wrote in message
news:d_Vic.75099$I83.1754097@twister.tampabay.rr.c om...
[color=blue]
> <script>
> function open(url){
>[/color]
window.open(url,"Picture","width=370,height=260,to olbar=no,menubar=no,resize[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.


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles