?
Solved

Open image on a new window

Posted on 2004-11-13
9
Medium Priority
?
229 Views
Last Modified: 2006-11-17
All I'm trying to do is open an image on a new window. Here is my code:

print "\n<tr>";
print "<td rowspan='2'>" . "<a href='#' onclick=\'window.open
('img src=$Row[SP1],directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\' target=\"_blank\">" . "</a></td>";
print "\<\tr>";

I do not get an error but the image dose not show up.

So 2 thing I want my image to show up as a link and went the usser clicks on the link I want the image to show up on a new window.

Thanks

Rafael
0
Comment
Question by:rcleon
  • 5
  • 2
  • 2
9 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12576261
Try this code

print "\n<tr>";
print "<td rowspan='2'>" . "<a href='#' onclick=\"window.open('" . $Row['SP1'] ."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\">" . "linkname</a></td>";
print "<tr>";
0
 

Author Comment

by:rcleon
ID: 12576301
Thanks,

It is almost there linkname is a small image of SP1 Now the image does not show but the name linkname does and went I click the new window opens with the large picture the small picture is SP1 and the large picture is LP1.


print "\n<tr>";
print "<td rowspan='2'>" . "<a href='#' onclick=\"window.open('" . $Row['LP1'] ."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\">" . "this should be $row['SP1']</a></td>";
print "<tr>";

Or something like that.

Thanks for you quick responce.

Rafael
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 1000 total points
ID: 12576367
write this
"this should be $row['SP1']</a></td>"
as
"this should be " . $row['SP1'] ."</a></td>"

Have a look at http://de3.php.net/manual/en/language.types.string.php#language.types.string.parsing how to use quotes correctly when using variables (special arrays)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rcleon
ID: 12576440
OK almost

print "<td rowspan='2'>" . "<a href='#' onclick=\"window.open(' ."<img src=\"$Row[LP1]\">" . ','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\">" . "<img src=\"$Row[SP1]\" border='0'>" ."</a></td>";

I get an error
Parse error: parse error, unexpected T_STRING in /home/mendoc2/public_html/content/moreinfo.php on line 253

Thanks fir the reference

Rafael
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12576472
You seen to have a little bit of confused coding there, perhaps:

print "<td rowspan='2'><a href='#' onclick=\"window.open('".$Row['LP1']."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";
0
 

Author Comment

by:rcleon
ID: 12576517
Almost

print "<td rowspan='2'><a href='#' onclick=\"window.open('".<img src=\"$Row['LP1']\">."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";


.$Row['LP1'] is an image also LP1 is a large image and SP1 is a small image went I click on sp1 the small image I want LP1 the large image to open on a new window.

Thanks

Rafael
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 1000 total points
ID: 12576535
i see, don't think you can do that, not directly anyway. The first parameter of the JS function window.open is the url eg:

print "<td rowspan='2'><a href='#' onclick=\"window.open('http://domain.com/page.php','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";

so you would either have to create a page for the image and load it in that or make the age dynamic and feed the image to load to it via the query string, eg:

print "<td rowspan='2'><a href='#' onclick=\"window.open('http://domain.com/page.php?img=".$Row['LP1']."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";

Then in page.php for example you would do something like:

<img src="<?php echo $_GET['img']; ?>">

Thats a very basic example, you might need to urlencode the image name for the query string and validate the input on your page.
0
 

Author Comment

by:rcleon
ID: 12576551
Thanks guys I made it work after reading the article on quotes the you guys reference about.

Thanks for all your help
0
 

Author Comment

by:rcleon
ID: 12576589
Guys I made it work here is the final code.

print "<td rowspan='2'><a href='#' onclick=\"window.open('".$Row['LP1']."','NameOfTheWindow', 'width=500,height=240,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";

Both of the images url are part of the MySQL database a small image apears on the page went you click on the small image a new page is loaded with the large image.

This is just what I wanted.

Once again Thanks you for all your help.

Rafael
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question