Forum Moderators: open
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
return false;
}
Here's an example of how I'm using it in the code:
<a href="wrigleysign.jpg" onclick="MM_openBrWindow('wrigleysign.jpg','','width=360,height=249');return false"><img src="wrigleysign.jpg" width="360" height="249" border="0"></a>
This works great, except for one thing: the image doesn't appear in the very top left-hand corner of the pop-up window -- there's some white space around it, and the right and bottom edges of the image are cut off, because they don't fit in the pop-up window. I'm wondering, is there some way around this problem, that's less messy than changing the width and height that I'm passing to the function every time?
Thanks in advance.
function imgWin(url,width,height) {
features= "width=" + width + ",height=" + height;
newWin = window.open ('', '', features);
pageCode = "<html><head><style type='text/css'>body {margin:0; padding:0; border:0;}</style></head>";
pageCode += "<body><img src='" + url + "'></body></html>";
newWin.document.write(pageCode);
newWin.document.close();
}
Reference it like this in the html:
<a href="image.jpg" onclick="imgWin(this.href,'640','480'); return false;">Click!</a>
As per Doc's first suggestion, this will open the new window to your image size, then write html code into it for displaying the image. The html is styled to get rid of the margins and padding, putting the image up in the top-left corner of the page.
Hope it helps.