By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jn
"Dariusz" <ng@lycaus.plusYOURSHIT.com> wrote in message
news:1_*********************@wards.force9.net...
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>


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.
Jul 17 '05 #2

P: n/a

"jn" <us********************************@jasonnorris.ne t> wrote in message
news:d_*********************@twister.tampabay.rr.c om...
<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')">


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.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.