[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Image Pop Up in new Window (same size as image)

Posted on 2012-03-21
2
Medium Priority
?
264 Views
Last Modified: 2012-04-27
Is there a way to make an image open in a new window showing a larger image of the same image? I want to make the window the same size of the image. I have lots of images (maps) so I hoping to use a javascript of something like (onclick open _blank)
0
Comment
Question by:Turfimage
2 Comments
 
LVL 16

Accepted Solution

by:
Rose Babu earned 800 total points
ID: 37752243
Hi,

get the image's height and width and use the same in the popupwindow property as like below.
<script language="javascript" type="text/javascript">
function imgPopup(imgURL) {
	x = new Image;
	x.src = imgURL;

	imgW = x.width;
	imgH = x.height;

	newwindow = window.open(imgURL, 'name', 'height=' + imgH + ',width=' + imgW + '');
	if (window.focus) {
		newwindow.focus()
	}
}
</script>


<img src="http://whatisprogramming.com/files/2011/10/javascript1.jpg" 
     onclick="imgPopup('http://whatisprogramming.com/files/2011/10/javascript1.jpg')" />

<img src="http://nabtron.com/wp-content/uploads/2011/09/javascript1.png" 
     onclick="imgPopup('http://nabtron.com/wp-content/uploads/2011/09/javascript1.png')" />

Open in new window

Hope this will work for you.
0
 

Author Comment

by:Turfimage
ID: 37904060
Yes this works.... Is there a way to make the new window pop up be ' resizable=yes '
  and add a 'menubar=yes' In this script?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month18 days, 4 hours left to enroll

829 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