HELP: Opening images in Pop-up

J

Joker

Hello,

I'm buidling a friends-website. I have bunch of pictures. I used the
javascript to open the images in real size in a pop-up.


<script language="JavaScript">
<!--
function nph_open_window(url, name, feature)
{
window.open(url, name, feature);
}
// -->
</script>


And I call it with:
<a href="javascript:nph_open_window('Foto/heid/heid10.jpg', 'heid10',
'width=550,height=400,toolbar=no,menubar=no,status=no,scrollbars=no,resizabl
e=no')"> <img src="Foto/heid/heid10l.jpg" width="102" height="72"
border="0"></a>


BUT when the pop-up opens, I see the LEFT and TOP border/margin. So it
doesn't fit exactly in the pop-up.

Can someone help me to fix it ?


Thanks !
 
M

McKirahan

Joker said:
Hello,

I'm buidling a friends-website. I have bunch of pictures. I used the
javascript to open the images in real size in a pop-up.


<script language="JavaScript">
<!--
function nph_open_window(url, name, feature)
{
window.open(url, name, feature);
}
// -->
</script>


And I call it with:
<a href="javascript:nph_open_window('Foto/heid/heid10.jpg', 'heid10',
'width=550,height=400,toolbar=no,menubar=no,status=no,scrollbars=no,resizabl
e=no')"> <img src="Foto/heid/heid10l.jpg" width="102" height="72"
border="0"></a>


BUT when the pop-up opens, I see the LEFT and TOP border/margin. So it
doesn't fit exactly in the pop-up.

Can someone help me to fix it ?


Thanks !

How about the following; watch for word-wrap:


<html>
<head>
<title>open_win.htm</title>
<script type="text/javascript">
function nph_open_window(url,wid,hgt) {
var nam = url.substring(url.lastIndexOf("/")+1,url.length-4);
var cfg = "width="+wid+",height="+hgt+",resizable=no";
var htm = "<html>";
htm += "<body leftmargin='0' topmargin='0'>";
htm += "<img src='" + url +"' border='0' alt=''>";
htm += "</body>";
htm += "</html>";
var win = window.open("",nam,cfg);
win.document.write(htm);
}
</script>
</head>
<body>
<img src="Foto/heid/heid10l.jpg"
border="0" width="102" height="72"
alt="Click to enlarge." style="cursor:hand"
onclick="nph_open_window('Foto/heid/heid10.jpg',550,400)">
</body>
</html>


Since you may have pictures of different sizes, the dimensions are passed to
the finction.

Note that your thumbnail images may be distorted if they're all displayed at
102 x 72.


Also, here's some info on the window.open method:
http://www.devguru.com/Technologies/ecmascript/quickref/win_open.html
 
M

Michael Schmitt

McKirahan wrote:

--- snip ---

###########################################################
htm += "<body leftmargin='0' topmargin='0'>";
###########################################################
leftmargin and topmargin did never belong to the HTML-standard
as defined by the W3C, better use CSS instead:
html += "<body style='margin: 0'>"

--- snip ---

cu, Michael
 
M

Myron Turner

I used the javascript to open the images in real size in a pop-up.


<script language="JavaScript">
<!--
function nph_open_window(url, name, feature)
{
window.open(url, name, feature);
}
// -->
</script>


And I call it with:
<a href="javascript:nph_open_window('Foto/heid/heid10.jpg', 'heid10',
'width=550,height=400,toolbar=no,menubar=no,status=no,scrollbars=no,resizabl
e=no')"> <img src="Foto/heid/heid10l.jpg" width="102" height="72"
border="0"></a>


BUT when the pop-up opens, I see the LEFT and TOP border/margin. So it
doesn't fit exactly in the pop-up.

Not clear what you mean by LEFT and TOP. In any event, how big is the
image? Is it 550 x 400? If so, then you have to leave enough room
for margins around the image. 550 x 400 would be the total size of the
window, not counting the borders and title bar.



Myron Turner
www.room535.org
 
M

Mark Preston

Joker said:
Hello,

I'm buidling a friends-website. I have bunch of pictures. I used the
javascript to open the images in real size in a pop-up.
Just in passing - what about browsers (such as all the modern ones) that
can stop pop-ups (and do so by default)?
 
J

Joker

Thank you very much !!


Michael Schmitt said:
McKirahan wrote:

--- snip ---

###########################################################
###########################################################
leftmargin and topmargin did never belong to the HTML-standard
as defined by the W3C, better use CSS instead:
html += "<body style='margin: 0'>"

--- snip ---

cu, Michael
 
M

Michael Schmitt

Mark said:
Just in passing - what about browsers (such as all the modern ones) that
can stop pop-ups (and do so by default)?

My Mozilla is configured to block unrequested popups. But in this case the
popup-window is _not_ unrequested, so it opens as wanted. A different
question would be, what's about people, who have javascript disabled?

cu Michael
 
T

Thomas 'PointedEars' Lahn

Michael said:
###########################################################

Please learn how to quote in Usenet.
leftmargin and topmargin did never belong to the HTML-standard
as defined by the W3C,
Correct.

better use CSS instead:
html += "<body style='margin: 0'>"

The CSS equivalent would be <body style='margin-left:0; margin-top:0'>.
Your code removes the margins on all sides.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,200
Latest member
LaraHunley

Latest Threads

Top