/    Sign up×
Community /Pin to ProfileBookmark

popup picture

I am trying to make a popup window to display a picture. But when I do the picture is off center, i am pointing it to a .jpg file instead of an html file, i want to be able to do that so i don’t have to make a webpage just to display a picture. How can i do it so the picture is center (i am setting the popup window size to the exact size of the picture and it still seems to have white space around it) If i have to have white space around the picture how can i make it black?
thanx

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@cootheadJun 14.2004 — Hi there wakkoguy,


If you use a pop-up window to display images,

you will have the problem of white space

to the top and the left of the image :mad:

This can be resolved by putting the image

in an .html file and then setting the

margin and the padding tp 0.

However pop-up blockers may still upset you plans :mad:

So try this code which makes an immitation pop-up ? ....
[color=navy]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Immitation pop-up</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
div#container {
position:absolute;
top:10px;
left:200px;
display:none;

<i> </i> border:solid 1px #000000;
}
div.thumbs {
margin:5px 0 0 0;
width:100px;
border:solid 1px #000000;
background:#ffffff;
}

table#popup {
border-collapse:collapse;
}
td#bar {
background:#4a6ba1;
border:4px solid #bbbbbb;
font-family:arial;
font-size:13px;
font-weight:bold;
text-align:right;
}
td#large {
border:4px solid #bbbbbb;
}
a {
background:#bbbbbb;
color:#000000;
text-decoration:none;
}
img.small {
width:100px;
height:100px;
}
span#title {
color:#ffffff;
float:left;
}
/*//]]&gt;*/
&lt;/style&gt;

&lt;script type="text/javascript"&gt;
//&lt;![CDATA[

function popUp(n){

var images=new Array('http://hstrial-dbayly.homestead.com/files/ten_quid.jpg','http://hstrial-dbayly.homestead.com/files/dog.jpg');
var titled=new Array('ten pounds','odd dog');
var width=new Array('445','400');
var height=new Array('238','432');

<i> </i> document.getElementById('container').style.display="block";
<i> </i> document.getElementById('large').style.width=width[n]+'px';
<i> </i> document.getElementById('large').style.height=height[n]+'px';
<i> </i> document.getElementById('large').style.background='url('+images[n]+')';
<i> </i> document.getElementById('title').innerHTML=titled[n];
}

function popOff() {
document.getElementById('container').style.display="none";
}
//]]&gt;
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div class="thumbs"&gt;&lt;img class="small" alt="" src="http://hstrial-dbayly.homestead.com/files/ten_quid.jpg" onclick="popUp(0);return false"/&gt;&lt;/div&gt;
&lt;div class="thumbs"&gt;&lt;img class="small" alt="" src="http://hstrial-dbayly.homestead.com/files/dog.jpg" onclick="popUp(1);return false"/&gt;&lt;/div&gt;

&lt;div id="container"&gt;
&lt;table id="popup"&gt;&lt;tr&gt;
&lt;td id="bar"&gt;&lt;span id="title"&gt;&lt;/span&gt;&lt;a href="#"onclick="popOff();return false"&gt;&amp;#160;X&amp;#160;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;
&lt;td id="large"&gt;&amp;#160;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;[/color]


[i]coothead[/i]
Copy linkTweet thisAlerts:
@randomAug 01.2004 — just load up html documents instead of images. make the html document have the image as the background. use this code for each pop-up link.

<head>

<script languange="JavaScript">

<!--

function photopopup(link, width, height)

{ var photoWindow = window.open(link,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height); } //-->

</script>

</head>


then you need to know your image height and width. link your image like this.

<a href="javascript:photopopup('image.html','100','100')">click here for image pop-up</a>
Copy linkTweet thisAlerts:
@I1O0O1IAug 10.2004 — [i]Originally posted by random [/i]

[B]just load up html documents instead of images. make the html document have the image as the background. use this code for each pop-up link.



<head>

<script languange="JavaScript">

<!--

function photopopup(link, width, height)

{ var photoWindow = window.open(link,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height); } //-->



</script>

</head>





then you need to know your image height and width. link your image like this.



<a href="javascript:photopopup('image.html','100','100')">click here for image pop-up</a> [/B]
[/QUOTE]


this code = no worky ?
Copy linkTweet thisAlerts:
@dutchcampAug 20.2004 — I am in search of the same answer. I have a gallery with about 107 photos, and to create html pages for each of them is somewhat of a pain, if i wanted to do that, i'd just position them absolutely. But is there not a way to set the margin in javscript> i tried onLoad=leftmargin... errr, i dont quite remember the exact code, but the point is, it didn't work. it works for onclick, but not onload. any help would be much appreciated. I'm just using a generic code for popups

<td>

<a href="clickity" onClick="PICS=window.open('image.jpg','PICS','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=500, height=283'); return false;">

<img border="0" src="thumbnails/image.jpg" width="100" height="57" position="absolute" left="0" top="0">

</td>
×

Success!

Help @wakkoguy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...