[SOLVED] php - open new window with picture in it
Moderator: General Moderators
php - open new window with picture in it
How to open new window (with php) without toolbar, statusbar, standard buttons, address bar, links, (in one word - without anything), but with picture in it.
$Slika7="something.jpg";
echo "<img src="'. $Slika7 .'" border="0"></a>";
$Slika7="something.jpg";
echo "<img src="'. $Slika7 .'" border="0"></a>";
If, for example, you want to open image_y.jpg in a window, via a user-click, you would have to put "image_y.jpg" in the URL of the link, or somehow pass it to the new page.
So, if your HTML was like this:
your javascript would be like this:
(the variable "features" is a string that sets properties of the window. Do a google search on [google]Javascript: window.open[/google] to find out about that.)
Then, in your PHP page,
So, if your HTML was like this:
Code: Select all
<a href = "javascript:open_image_window('image_y.jpg');">
<img src = "image_y_thumb.jpg">
</a>Code: Select all
function open_image_window(image_name)
{
window.open('single_image_view.php?image=' + image_name','newWindow',features);
}Then, in your PHP page,
Code: Select all
<?PHP
$image_to_display=$_GET['image'];
echo <<<IMAGE
<img src = "$image_to_display">
IMAGE;
?>
Last edited by pickle on Tue Jun 15, 2004 3:58 pm, edited 2 times in total.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I've resolved problem in this way.
This is first page.
<?
$slika= "slike/zaglavlje/reljef_1.gif";
$img_src1="slike/strana/5star.gif";
print ('
<IMG SRC="' . $img_src1 . '" onclick="javascript:window.open(''veliki_tumbnail.php?slika='.urlencode($slika).''', ''WindowName'',''menubar=no, scrollbars=no, status=no, widith=150, hight=600, resizable=no, titlebar=no, toolbar=no'')"> ');
?>
And code in second page called "'veliki_tumbnail.php" is
<?
echo '<img src="'. $slika .'" border="-1"></a>';
?>
My question is why page is not opening in
widith=150, hight=600 like I wanna.
This is first page.
<?
$slika= "slike/zaglavlje/reljef_1.gif";
$img_src1="slike/strana/5star.gif";
print ('
<IMG SRC="' . $img_src1 . '" onclick="javascript:window.open(''veliki_tumbnail.php?slika='.urlencode($slika).''', ''WindowName'',''menubar=no, scrollbars=no, status=no, widith=150, hight=600, resizable=no, titlebar=no, toolbar=no'')"> ');
?>
And code in second page called "'veliki_tumbnail.php" is
<?
echo '<img src="'. $slika .'" border="-1"></a>';
?>
My question is why page is not opening in
widith=150, hight=600 like I wanna.
It always concerns me when I see file paths being sent via the querystring and then just plonked in...
In this case it probably wouldn't be much of an issue as it's an image that's being output.
If I need to pass a file name I usually don't include the path or extension (as these are usually known by the script) and then do this to it:
This strips out any nonword characters (but leaves underscores).
Is it just me that does this kind of thing, am I being TOO paranoid?!?!?!
In this case it probably wouldn't be much of an issue as it's an image that's being output.
If I need to pass a file name I usually don't include the path or extension (as these are usually known by the script) and then do this to it:
Code: Select all
<?php
$filename = preg_replace("/\W/", "", $filename);
$path = '/blah/blah/'.$filename.'.ext';
?>Is it just me that does this kind of thing, am I being TOO paranoid?!?!?!