Beginner question about onclick=window.open

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mudge.steve
Forum Newbie
Posts: 10
Joined: Thu Apr 22, 2010 3:28 pm

Beginner question about onclick=window.open

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Beginner question about onclick=window.open

Post 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.
mudge.steve
Forum Newbie
Posts: 10
Joined: Thu Apr 22, 2010 3:28 pm

Re: Beginner question about onclick=window.open

Post 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!
mudge.steve
Forum Newbie
Posts: 10
Joined: Thu Apr 22, 2010 3:28 pm

Re: Beginner question about onclick=window.open

Post 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.'/';
?>
mudge.steve
Forum Newbie
Posts: 10
Joined: Thu Apr 22, 2010 3:28 pm

Re: Beginner question about onclick=window.open

Post 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?
mudge.steve
Forum Newbie
Posts: 10
Joined: Thu Apr 22, 2010 3:28 pm

Re: Beginner question about onclick=window.open

Post by mudge.steve »

Something like this maybe:

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

:oops:
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Beginner question about onclick=window.open

Post 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.
Post Reply