window.open gives excess image padding in IE6

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Becky Carter Hickman-Jones

    window.open gives excess image padding in IE6

    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','heigh t=xxx,
    width=xxx');ret urn 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


  • Grant Wagner

    #2
    Re: window.open gives excess image padding in IE6

    Becky Carter Hickman-Jones wrote:
    [color=blue]
    > 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','heigh t=xxx,
    > width=xxx');ret urn 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[/color]

    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 <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.


    * 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


    Comment

    • Becky Carter Hickman-Jones

      #3
      Re: window.open gives excess image padding in IE6

      "Grant Wagner" <gwagner@agrico reunited.com> wrote in message
      news:40DC8A24.1 8C39697@agricor eunited.com...[color=blue]
      > Becky Carter Hickman-Jones wrote:[color=green]
      > >
      > > I have a simple script that opens an image in a new window which is[/color][/color]
      sized to[color=blue][color=green]
      > > the image. The script is as follows: <a title="xxx"
      > >[/color][/color]
      onclick="window .open('http://www.[sitename].com/photos/xxx.jpg','heigh t=xxx,[color=blue][color=green]
      > > width=xxx');ret urn 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.[/color][/color]
      The[color=blue][color=green]
      > > window is not resizable, and some of the image is therefore cropped. I[/color][/color]
      don't[color=blue][color=green]
      > > notice this with Safari or Camino. Is this a bug in IE? Is there a way[/color][/color]
      to[color=blue][color=green]
      > > 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[/color]
      >
      > Microsoft Internet Explorer includes the default "margin" style[/color]
      attributes, even[color=blue]
      > on pages that are loaded as a .jpg. If you want to avoid this, load a[/color]
      ..html file[color=blue]
      > that embeds the image you want to display and includes:
      >
      > <style type="text/css">
      > body { margin: 0px; }
      > </style>
      >
      > --
      > | Grant Wagner <gwagner@agrico reunited.com>
      >[/color]


      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


      Comment

      • Randy Webb

        #4
        Re: window.open gives excess image padding in IE6

        Becky Carter Hickman-Jones wrote:
        [color=blue]
        > "Grant Wagner" <gwagner@agrico reunited.com> wrote in message
        > news:40DC8A24.1 8C39697@agricor eunited.com...[/color]

        <--snip-->
        [color=blue][color=green]
        >>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>
        >>[/color]
        >
        > 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.
        >[/color]

        <a href="URLToImag e" onclick="window .open('blank.ht ml?' +
        (this.href.subs tring(this.href .lastIndexOf('/')+1,this.href. length)));retur n
        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,lo cation.search.l ength)) + ' rest of img tag
        here>'

        </script>

        --
        Randy
        Chance Favors The Prepared Mind
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        Working...