Solved

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

Posted on 2012-03-21
2
250 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 200 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
remove border from element 5 77
Where can I find... 1 30
Not seen Link button 5 37
PHP Form Calculate Total Price 10 41
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

776 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