By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,180 Members | 1,202 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,180 IT Pros & Developers. It's quick & easy.

window.open gives excess image padding in IE6

P: n/a
Hi,

I have a simple script that opens an image in a new window which is sized to
the image. The script is as follows: <a title="xxx"
onclick="window.open('http://www.[sitename].com/photos/xxx.jpg','height=xxx,
width=xxx');return false" href="#">link text</a>

This script works very well for my needs, however, in IE6, the resulting
opened window has unnecessary padding on the top and left sides of the
image, which pushes the image down and to the right inside the window. The
window is not resizable, and some of the image is therefore cropped. I don't
notice this with Safari or Camino. Is this a bug in IE? Is there a way to
compensate for this extra padding in IE? Is there a more elegant way of
executing this script to avoid the problem altogether?

I would appreciate any advice.

Cheers,
Beck
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Becky Carter Hickman-Jones wrote:
Hi,

I have a simple script that opens an image in a new window which is sized to
the image. The script is as follows: <a title="xxx"
onclick="window.open('http://www.[sitename].com/photos/xxx.jpg','height=xxx,
width=xxx');return false" href="#">link text</a>

This script works very well for my needs, however, in IE6, the resulting
opened window has unnecessary padding on the top and left sides of the
image, which pushes the image down and to the right inside the window. The
window is not resizable, and some of the image is therefore cropped. I don't
notice this with Safari or Camino. Is this a bug in IE? Is there a way to
compensate for this extra padding in IE? Is there a more elegant way of
executing this script to avoid the problem altogether?

I would appreciate any advice.

Cheers,
Beck


Microsoft Internet Explorer includes the default "margin" style attributes, even
on pages that are loaded as a .jpg. If you want to avoid this, load a .html file
that embeds the image you want to display and includes:

<style type="text/css">
body { margin: 0px; }
</style>

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2

P: n/a
"Grant Wagner" <gw*****@agricoreunited.com> wrote in message
news:40***************@agricoreunited.com...
Becky Carter Hickman-Jones wrote:

I have a simple script that opens an image in a new window which is sized to the image. The script is as follows: <a title="xxx"
onclick="window.open('http://www.[sitename].com/photos/xxx.jpg','height=xxx, width=xxx');return false" href="#">link text</a>

This script works very well for my needs, however, in IE6, the resulting
opened window has unnecessary padding on the top and left sides of the
image, which pushes the image down and to the right inside the window. The window is not resizable, and some of the image is therefore cropped. I don't notice this with Safari or Camino. Is this a bug in IE? Is there a way to compensate for this extra padding in IE? Is there a more elegant way of
executing this script to avoid the problem altogether?

I would appreciate any advice.

Cheers,
Beck
Microsoft Internet Explorer includes the default "margin" style

attributes, even on pages that are loaded as a .jpg. If you want to avoid this, load a ..html file that embeds the image you want to display and includes:

<style type="text/css">
body { margin: 0px; }
</style>

--
| Grant Wagner <gw*****@agricoreunited.com>

Thank you for the tip. I use this script on a blog, and this blog often has
pictures that I want to show off. So, your tip would mean that I have to
create a brand new html page for every picture that I want to show? I'm
still new to this, so I appreciate your patience.

Beck
Jul 23 '05 #3

P: n/a
Becky Carter Hickman-Jones wrote:
"Grant Wagner" <gw*****@agricoreunited.com> wrote in message
news:40***************@agricoreunited.com...


<--snip-->
Microsoft Internet Explorer includes the default "margin" style
attributes, even on pages that are loaded as a .jpg. If you want
to avoid this, load a ..html file that embeds the image you want to
display and includes:

<style type="text/css">
body { margin: 0px; }
</style>


Thank you for the tip. I use this script on a blog, and this blog often has
pictures that I want to show off. So, your tip would mean that I have to
create a brand new html page for every picture that I want to show? I'm
still new to this, so I appreciate your patience.


<a href="URLToImage" onclick="window.open('blank.html?' +
(this.href.substring(this.href.lastIndexOf('/')+1,this.href.length)));return
false"><img src="URLToImage" width="##" height........></a>

Wrap that around each image. Then, in imagePage.html, have script that
will read the query string and display the appropriate image, along with
the styles that you need:

<script type="text/javascript">
document.write('<img src="' +
location.search.substring(1,location.search.length )) + ' rest of img tag
here>'

</script>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.