Help - Search - Members - Calendar
Full Version: showing image in popup, remove page padding
Weborum Webmaster Forum > Web Page Design > Javascript
leo
ok i'm using a simple popup script to show large versions of a thumbnail, would it be possible to somehow set the popup to have no padding or margin?

this is the code i would be using:

CODE




<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=400');");
}
// End -->





<a href="javascript:popUp('images/image.jpg')"><img style="margin-left:15px;margin-right:15px;border:2px solid white;" src="images/imagebigl.jpg" width="100" height="100" alt="" border="0"></a>

cheers smile.gif
Waleed
is there a way to bump the window type thing

i mean pop-up just the image, without window
leo
you could by hiding ans showing layers which is fine if you want to spend the time doing it wink.gif
Willy Duitt
What's the problem Leo??
Is there a margin/line showing in the upper left of the window above the image??

There are several reasons this occurs, both attributed to default margin/padding of both the body and the image... Two ways of dealing with this is to open a blank window, document.write the HTML including style to remove the default margin/padding of the body and place the image into a division, once again using style to remove the default margin/padding... Or, much the same as the above, set the image as the body background...

CODE

<BASE HREF="http://www.xs4all.be/~chadier/webgallery_1/">
<script type="text/javascript">
<!--//
 function display(image,name){
  var theImage = new Image();
      theImage.src = image+'?'+new Date().getUTCSeconds();
      theImage.onerror = function(){
         alert('This image has failed to load!');
      }

      theImage.###### = function(){
       var width  = theImage.width;  if(width <100) { width  = 100 };
       var height = theImage.height; if(height<100) { height = 100 };
       var left = Math.round((screen.width - width) / 2);
       var top  = Math.round((screen.height - height) / 2);
       var features = 'top='+top+',left='+left+',width='+width+',height='+height;
       var openWindow = window.open('','display',features);
        with(openWindow.document){
          writeln('<html><head><title>'+name+'</title></head>');
          writeln('<body ######="self.focus()" onblur="self.close()"');
          writeln('style="background-image:url('+image+');');
          writeln('background-repeat:no-repeat;width:'+width+';height:'+height+'">');
          writeln('<div style="position:absolute;bottom:3px;text-align:center">');
          writeln('<span style="font-size:12px;width:100%">');
          writeln('<a href="javascript:self.close()">Close</a>');
          writeln('</span></div></body></html>');
          close();
        }
      }
          return false;
 }
//-->
</script>
</head>

<body>
<a href="images/17.jpg" name="Classic Table"
onclick="return display(this.href,this.name)">
<img src="thumbnails/17.jpg" width="55" height="70"></a>
<a href="images/18.jpg" name="Wrought Iron Table"
onclick="return display(this.href,this.name)">
<img src="thumbnails/18.jpg" width="55" height="70"></a>
<a href="images/19.jpg" Name="Wrought Iron Sculpture"
onclick="return display(this.href,this.name)">
<img src="thumbnails/19.jpg" width="55" height="70"></a>


I'm not sure if this is the most recent example of this popup code that I have... I know I have fixed a bug which occurs when the same image is called twice in a row and is cached and thus the ###### does not fire.... Not sure if this is the updated version and I am too lazy to look any further unless I know this is what you want...

.....Willy

Edit: Once again... ##### == onload
leo
that's right Willy, space top and left of the image. i'll confirm i've got it working when i get back from seeing a client.

I recall something about writing in the html from something before smile.gif

cheers smile.gif
Willy Duitt
QUOTE(leo @ Mar 31 2005, 09:48 AM)
I recall something about writing in the html from something before smile.gif
[right][snapback]25571[/snapback][/right]


Yes, there is a long thread over at HTML forums regarding this same problem... whistle.gif

.....Willy
Waleed
QUOTE(leo @ Mar 31 2005, 05:28 PM)
you could by hiding ans showing layers which is fine if you want to spend the time doing it wink.gif
[right][snapback]25563[/snapback][/right]


blink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.