Page 1 of 1

Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 3:33 pm
by mudge.steve
Hello

I am pretty new to php and web development. Have many years programming in other langs.

here is my question. How can I get the following to work correctly.

<?php
$str_MyNewPic='/home/mudgeste/public_html/photo_Gallery/public/images/'.$photo->division.'/'.$photo->month.'_'.$photo->year.'/'$photo->filename.'/';
?>
<a onclick="window.open(<?php echo $str_MyNewPic; ?>, 'mywindow', 'width=800', 'height=200')" href="#">
<img src="<?php echo 'http://www.mudgesteve.com/photo_Gallery ... ->filename; ?>" />
<?php echo $str_MyNewPic; ?>
</a>

I am trying to open a very large picture in its own window.
currently '$str_MyNewPic' holds the path to the picture.

I thought the onclick="window.open(what page to view, name for the new window, width of it, height of it)" href="#"

Please help

Re: Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 3:45 pm
by requinix
What you have now is

Code: Select all

<a onclick="window.open($str_MyNewPic, 'mywindow', 'width=800', 'height=200')" href="#">
What you need is

Code: Select all

<a onclick="window.open('$str_MyNewPic', 'mywindow', 'width=800,height=200')" href="#">
See the differences? There are two.

Re: Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 3:47 pm
by mudge.steve
'$str_MyNewPic' and 'width=xxx,height=xxx'

I think are the differances..

Thanks fo ryour help i will try it straight away!

Re: Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 3:49 pm
by mudge.steve
Hello, Now I get a parse error for the following line:

<?php
$str_MyNewPic='/home/mudgeste/public_html/photo_Gallery/public/images/'.$photo->division.'/'.$photo->month.'_'.$photo->year.'/'$photo->filename.'/';
?>

Re: Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 3:52 pm
by mudge.steve
Hello

I saw the '.' missing, Replaced same and get this error from server

Not Found
The requested URL /photo_Gallery/public/admin/$str_MyNewPic was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

any ideas?

this var was set as a path to my picture. Should it be a http:// syntax?

Re: Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 3:53 pm
by mudge.steve
Something like this maybe:

$str_MyNewPic = 'http://www.mudgesteve.com/photo_Gallery ... ->filename.';'

:oops:

Re: Beginner question about onclick=window.open

Posted: Thu Apr 22, 2010 4:42 pm
by requinix
I was afraid that would happen...

You weren't supposed to copy and paste the code I gave you. The $str_MyNewPic was a placeholder for the whole <?php echo... ?> you had. You still need that.