pop up script!?!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wentink

    pop up script!?!

    Does anybody have a simple script that let's me popup a picture from a
    thumbnail?

    The ones i found are all very very complicated and messy in the source...

    Thanks,
    Tintin


  • kaeli

    #2
    Re: pop up script!?!

    In article <JPclb.385971$4 w.44701166@amsn ews03.chello.co m>,
    info@wentinkmod elbouw.nl enlightened us with...[color=blue]
    > Does anybody have a simple script that let's me popup a picture from a
    > thumbnail?
    >
    > The ones i found are all very very complicated and messy in the source...
    >[/color]

    Do you need it to popup in a window with specifications or just open in
    a new window?


    -------------------------------------------------
    ~kaeli~
    Jesus saves, Allah protects, and Cthulhu
    thinks you'd make a nice sandwich.


    -------------------------------------------------

    Comment

    • DB McGee

      #3
      Re: pop up script!?!

      "Wentink" <info@wentinkmo delbouw.nl> wrote in message
      news:JPclb.3859 71$4w.44701166@ amsnews03.chell o.com...[color=blue]
      > Does anybody have a simple script that let's me popup a picture from a
      > thumbnail?
      >
      > The ones i found are all very very complicated and messy in the source...
      >
      > Thanks,
      > Tintin
      >
      >[/color]



      Try this out (NOTE - you should probably store the javascript in a *.js file
      so you can reuse it). I tested this on IE6 and Mozilla 1.4.

      All you need to do is pass the src to the image to the imagePopup()
      function. Then you just need to call that function either in an <a> tag or
      using an onclick handler in a button or image or whatever you want. The
      script will dynamically determine the height and width of the image so you
      don't even need to include those (i find that makes setting the scripting up
      a lot easier in a page!).


      <html>
      <head>
      <title>Popup Image Test</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <script type="text/javascript">
      // Variable to store a reference to the popup window
      var popupWindow

      /*
      Function: imagePopup()

      Description:

      Function to open an image in a popup window

      Function Parameters:

      ImageSource - REQUIRED - the src of the image to open in the popup window

      ImageWidth - OPTIONAL - the width of the image

      ImageHeight - OPTIONAL - the height of the image

      ImageTitle - OPTIONAL - the title for the image - used in the <title>
      attribute in the popup window

      PopupTitle - OPTIONAL - the window.name property for the popup window

      */
      function imagePopup( ImageSource, ImageWidth, ImageHeight, ImageTitle,
      PopupTitle ) {

      /*
      1. PROCESS THE PASSED FUNCTION VALUES
      */

      // Set default values if none were passed
      PopupTitle = ( PopupTitle == '' ) ? 'imgPopup' : PopupTitle; // Note - this
      must not contain any spaces
      ImageTitle = ( ImageTitle == '' ) ? ImageSource : ImageTitle; // Use the
      image src as the default title if none was passed

      // See if we need to dynamically grab the Image width dimensions if none
      were passed in the function
      if ( ImageWidth == '' || typeof( ImageWidth ) == "undefined" ) {
      // If no image width was passed - preload the image then grab the width
      value from the preloaded image
      theImage = new Image();
      theImage.src = ImageSource;
      ImageWidth = theImage.width;
      }
      // See if we need to dynamically grab the Image width dimensions if none
      were passed in the function
      if ( ImageHeight == '' || typeof( ImageHeight ) == "undefined" ) {
      ImageHeight = theImage.height ;
      }


      /*
      2. CALCULATE CENTERING VALUES FOR THE POPUP WINDOW
      */

      // I think this works in NS6+ & Mozilla )!
      if (document.all) {
      var xMax = screen.width;
      var yMax = screen.height;
      }
      else {
      if (document.layer s) {
      var xMax = window.outerWid th;
      var yMax = window.outerHei ght;
      }
      else {
      var xMax = 640;
      var yMax = 480;
      }
      }
      xOffset = (xMax - ImageWidth) / 2;
      yOffset = (yMax - ImageHeight) / 2;


      /*
      3. SETUP POPUP WINDOW VALUES
      */

      /* Set the various features for the preview window - width, height,
      titlebar etc. */
      var popupFeatures =
      'width=' + ImageWidth +
      ',height=' + ImageHeight +
      ',screenX=' + xOffset +
      ',screenY=' + yOffset +
      ',top=' + yOffset +
      ',left=' + xOffset


      /*
      4. CREATE AND OPEN THE POPUP WINDOW
      */

      popupWindow = window.open('', PopupTitle,popu pFeatures);
      // Set the window opener
      if ( popupWindow.ope ner == null ) {
      popupWindow.ope ner = self;
      }
      popupWindow.foc us();


      /*
      5. WRITE THE ACTUAL IMAGE TO THE POPUP WINDOW
      */

      // Create the default HTML content for the popup window
      var popupContent = ""
      popupContent += "\n<html><head> <title>" + ImageTitle + "</title><meta
      http-equiv='Content-Type' content='text/html; charset=iso-8859-1'></head>"
      popupContent += "\n<body style='margin: 0px; padding: 0px;'>" // Need to
      make sure the <body> has no padding or margin or the image will be
      off-kilter
      popupContent += "\n<div align='center'> "
      popupContent += "<img id='popupimage' >" // This is the <img> that we
      replace the src, width & height (see below)
      popupContent += "</div>"
      popupContent += "\n</body>"
      popupContent += "\n</html>"
      popupWindow.doc ument.write( popupContent )
      popupWindow.doc ument.close()

      // Now write the data for the image (src, width & height)
      oPopupImg = popupWindow.doc ument.getElemen tById('popupima ge'); // Create
      an object reference to the <img> in the popup window
      oPopupImg.src = ImageSource; // Replace the source
      oPopupImg.width = ImageWidth;
      oPopupImg.heigh t = ImageHeight;

      }
      </script>
      </head>

      <body>
      <h1>Image Popup Test</h1>
      <input type="button" name="view" value="view" onclick="imageP opup(
      'http://www.mystudios.c om/art/impress/monet/monet-wheat-field-1881.jpg' )"/>
      </body>
      </html>


      Comment

      • DB McGee

        #4
        Re: pop up script!?!

        Slight modification - I forgot to preload the image in the case where no
        ImageHeight was passed - I was relying on the fact that no ImageWidth would
        be passed as well (which is probably true in 99% of the cases - but just to
        be sure)

        THE CHANGES:

        Find this:


        // See if we need to dynamically grab the Image width dimensions if none
        were passed in the function
        if ( ImageHeight == '' || typeof( ImageHeight ) == "undefined" ) {
        ImageHeight = theImage.height ;
        }


        And replace it with:

        // See if we need to dynamically grab the Image height dimensions if none
        were passed in the function
        if ( ImageHeight == '' || typeof( ImageHeight ) == "undefined" ) {
        theImage = new Image();
        theImage.src = ImageSource;
        ImageHeight = theImage.height ;
        }



        "DB McGee" <noreply@norepl y.com> wrote in message
        news:DEilb.1639 $h61.216@news01 .bloor.is.net.c able.rogers.com ...[color=blue]
        > "Wentink" <info@wentinkmo delbouw.nl> wrote in message
        > news:JPclb.3859 71$4w.44701166@ amsnews03.chell o.com...[color=green]
        > > Does anybody have a simple script that let's me popup a picture from a
        > > thumbnail?
        > >
        > > The ones i found are all very very complicated and messy in the[/color][/color]
        source...[color=blue][color=green]
        > >
        > > Thanks,
        > > Tintin
        > >
        > >[/color]
        >
        >
        >
        > Try this out (NOTE - you should probably store the javascript in a *.js[/color]
        file[color=blue]
        > so you can reuse it). I tested this on IE6 and Mozilla 1.4.
        >
        > All you need to do is pass the src to the image to the imagePopup()
        > function. Then you just need to call that function either in an <a> tag[/color]
        or[color=blue]
        > using an onclick handler in a button or image or whatever you want. The
        > script will dynamically determine the height and width of the image so you
        > don't even need to include those (i find that makes setting the scripting[/color]
        up[color=blue]
        > a lot easier in a page!).
        >
        >
        > <html>
        > <head>
        > <title>Popup Image Test</title>
        > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        > <script type="text/javascript">
        > // Variable to store a reference to the popup window
        > var popupWindow
        >
        > /*
        > Function: imagePopup()
        >
        > Description:
        >
        > Function to open an image in a popup window
        >
        > Function Parameters:
        >
        > ImageSource - REQUIRED - the src of the image to open in the popup[/color]
        window[color=blue]
        >
        > ImageWidth - OPTIONAL - the width of the image
        >
        > ImageHeight - OPTIONAL - the height of the image
        >
        > ImageTitle - OPTIONAL - the title for the image - used in the <title>
        > attribute in the popup window
        >
        > PopupTitle - OPTIONAL - the window.name property for the popup window
        >
        > */
        > function imagePopup( ImageSource, ImageWidth, ImageHeight, ImageTitle,
        > PopupTitle ) {
        >
        > /*
        > 1. PROCESS THE PASSED FUNCTION VALUES
        > */
        >
        > // Set default values if none were passed
        > PopupTitle = ( PopupTitle == '' ) ? 'imgPopup' : PopupTitle; // Note -[/color]
        this[color=blue]
        > must not contain any spaces
        > ImageTitle = ( ImageTitle == '' ) ? ImageSource : ImageTitle; // Use the
        > image src as the default title if none was passed
        >
        > // See if we need to dynamically grab the Image width dimensions if none
        > were passed in the function
        > if ( ImageWidth == '' || typeof( ImageWidth ) == "undefined" ) {
        > // If no image width was passed - preload the image then grab the width
        > value from the preloaded image
        > theImage = new Image();
        > theImage.src = ImageSource;
        > ImageWidth = theImage.width;
        > }
        > // See if we need to dynamically grab the Image width dimensions if none
        > were passed in the function
        > if ( ImageHeight == '' || typeof( ImageHeight ) == "undefined" ) {
        > ImageHeight = theImage.height ;
        > }
        >
        >
        > /*
        > 2. CALCULATE CENTERING VALUES FOR THE POPUP WINDOW
        > */
        >
        > // I think this works in NS6+ & Mozilla )!
        > if (document.all) {
        > var xMax = screen.width;
        > var yMax = screen.height;
        > }
        > else {
        > if (document.layer s) {
        > var xMax = window.outerWid th;
        > var yMax = window.outerHei ght;
        > }
        > else {
        > var xMax = 640;
        > var yMax = 480;
        > }
        > }
        > xOffset = (xMax - ImageWidth) / 2;
        > yOffset = (yMax - ImageHeight) / 2;
        >
        >
        > /*
        > 3. SETUP POPUP WINDOW VALUES
        > */
        >
        > /* Set the various features for the preview window - width, height,
        > titlebar etc. */
        > var popupFeatures =
        > 'width=' + ImageWidth +
        > ',height=' + ImageHeight +
        > ',screenX=' + xOffset +
        > ',screenY=' + yOffset +
        > ',top=' + yOffset +
        > ',left=' + xOffset
        >
        >
        > /*
        > 4. CREATE AND OPEN THE POPUP WINDOW
        > */
        >
        > popupWindow = window.open('', PopupTitle,popu pFeatures);
        > // Set the window opener
        > if ( popupWindow.ope ner == null ) {
        > popupWindow.ope ner = self;
        > }
        > popupWindow.foc us();
        >
        >
        > /*
        > 5. WRITE THE ACTUAL IMAGE TO THE POPUP WINDOW
        > */
        >
        > // Create the default HTML content for the popup window
        > var popupContent = ""
        > popupContent += "\n<html><head> <title>" + ImageTitle + "</title><meta
        > http-equiv='Content-Type' content='text/html; charset=iso-8859-1'></head>"
        > popupContent += "\n<body style='margin: 0px; padding: 0px;'>" // Need to
        > make sure the <body> has no padding or margin or the image will be
        > off-kilter
        > popupContent += "\n<div align='center'> "
        > popupContent += "<img id='popupimage' >" // This is the <img> that we
        > replace the src, width & height (see below)
        > popupContent += "</div>"
        > popupContent += "\n</body>"
        > popupContent += "\n</html>"
        > popupWindow.doc ument.write( popupContent )
        > popupWindow.doc ument.close()
        >
        > // Now write the data for the image (src, width & height)
        > oPopupImg = popupWindow.doc ument.getElemen tById('popupima ge'); // Create
        > an object reference to the <img> in the popup window
        > oPopupImg.src = ImageSource; // Replace the source
        > oPopupImg.width = ImageWidth;
        > oPopupImg.heigh t = ImageHeight;
        >
        > }
        > </script>
        > </head>
        >
        > <body>
        > <h1>Image Popup Test</h1>
        > <input type="button" name="view" value="view" onclick="imageP opup(
        >[/color]
        'http://www.mystudios.c om/art/impress/monet/monet-wheat-field-1881.jpg' )"/>[color=blue]
        > </body>
        > </html>
        >
        >[/color]


        Comment

        • Richard Cornford

          #5
          Re: pop up script!?!

          "DB McGee" <noreply@norepl y.com> wrote in message
          news:DEilb.1639 $h61.216@news01 .bloor.is.net.c able.rogers.com ...
          <snip>[color=blue]
          >Try this out (NOTE - you should probably store the javascript in a
          >*.js file so you can reuse it). I tested this on IE6 and Mozilla 1.4.[/color]
          <snip>[color=blue]
          > // See if we need to dynamically grab the Image width dimensions
          > // if none were passed in the function
          > if ( ImageWidth == '' || typeof( ImageWidth ) == "undefined" ) {
          > // If no image width was passed - preload the image then grab
          > // the width value from the preloaded image
          > theImage = new Image();
          > theImage.src = ImageSource;
          > ImageWidth = theImage.width;
          > }[/color]

          That is a very optimistic piece of code. Assuming that the Image
          constructor is not a non-functional dummy (as on ICEbrowser 5), setting
          the src will cause an asynchronous request to a server for the specified
          file (assuming that it is not in the browser cache already). That will
          take some time even on a fast connection, yet milliseconds (if that)
          later you are reading the width value from the image object. Not all
          Image object implementations transfer the dimensions of the image to the
          width and height properties anyway but those that do will no know the
          size of the image until the server at least starts to return it (it
          would need at least the first 10 bytes for a GIF file to know the image
          size).

          There are no truly cross-browser method of automatically determining the
          size of an image from its file. Some of the download timing problems can
          be avoided by using the Image.onload/abort/error events to attempt to
          read the image size after it has arrived, but that still assumes that
          the Image implementation will read that information from the file and
          make it available on the Image object (and that the events will be
          triggered properly).

          Probably the only truly reliable approach would be to have the script
          directly passed the required dimensions for the image.

          <snip>[color=blue]
          > // I think this works in NS6+ & Mozilla )![/color]

          It says above that you tested on Mozilla so you should know that NA6+
          and Mozilla will be using the default 640x480 values.
          [color=blue]
          > if (document.all) {
          > var xMax = screen.width;
          > var yMax = screen.height;
          > }
          > else {
          > if (document.layer s) {
          > var xMax = window.outerWid th;
          > var yMax = window.outerHei ght;
          > }
          > else {
          > var xMax = 640;
          > var yMax = 480;
          > }
          > }[/color]

          That block uses crazy logic, there is no relationship between a browser
          having a document.all collection and a window.screen object, and there
          is no relationship between the document.layers collection and
          window.outerWin dth/Height. There is, however, a direct relationship
          between the existence of window.screen in a browser and the existence of
          window.screen. Similarly, knowing that - typeof outerWidth == 'number' -
          would be a reasonable indicator that outerWidth/Height values where
          available on the browser (though there are a number of browsers that
          erroneously report the same values for outerWidth/Height as the
          (apparently) correct values that they use for innerHeigh/Width).

          So a decision logic that goes:-

          if(typeof screen != 'undefined'){
          // read screen object properties.
          }else if(typeof outerWidth == 'number){
          // use outerWidth and assume outerHeight for symmetry (or
          explicitly test it).
          }else{
          //default action
          }

          -would seem to exactly match the requirement of the preceding code while
          requiring no unsupported inferences about the browser DOM.

          But the actions of this code are also questionable. The screen width and
          height properties should almost never be preferred over the
          availWidth/Height values as they (sometimes) take into account various
          taskbars (the number, size and distribution of which cannot be assumed).
          outerWidth/Heigh will only be related to the screen dimensions if the
          browser window is maximised, which will almost never be the case on a
          monitor bigger than 19 inches. And the defaults are bigger than the
          entire screen size of most PDAs.

          Generally, trying to explicitly position a browser window is fraught
          with problems. On Opera's MDI interface there is every possibility that
          positioning a window based on the screen dimensions will place the
          window out of site. On multi-monitor displays some set-ups will have the
          new window positioned across screen boundaries (the one place that you
          don't want it), while other may have the new window appearing on a
          different monitor to the original browser window. Usually opening a new
          window without explicit positioning will allow the browser to put the
          new window in a position that it thinks makes sense, usually over the
          existing window but slightly offset towards its centre. Which means that
          the new window is going to be appearing in a position that reliably
          allows the user to be aware of it.

          <snip>[color=blue]
          > /* Set the various features for the preview window -
          > width, height, titlebar etc. */
          > var popupFeatures =
          > 'width=' + ImageWidth +
          > ',height=' + ImageHeight +
          > ',screenX=' + xOffset +
          > ',screenY=' + yOffset +
          > ',top=' + yOffset +
          > ',left=' + xOffset[/color]

          Assuming that at this point the ImageWidth and ImageHeigth variables do
          hold the dimensions of the image, you are making no allowance for window
          chrome. That is not surprising as it is extremely difficult to determine
          the size and distribution of window chrome, and assuming standard values
          cannot be valid across OSs and are almost always alterable under user
          preferences anyway.

          However, I observe that you are not providing specification for
          resizable or scrollbars, causing then to default to off. Removing these
          features places the onus on the script to ensure that the new window
          will be able to display all of its contents under _all_ circumstances
          because if the script gets this detail wrong there will be nothing that
          the user can do to access the content. As it stands this script does not
          even come close to achieving that level of reliability in its sizing
          decisions. But then I have never seen a script that does cover all of
          the possibilities (which leads me to suspect that it is just not
          possible to do so), which means that leaving the new window at least
          sizable and probably scrollable is probably the best approach towards
          addressing the issues of window pre-sizing.
          [color=blue]
          > /*
          > 4. CREATE AND OPEN THE POPUP WINDOW
          > */
          >
          > popupWindow = window.open('', PopupTitle,popu pFeatures);[/color]

          As some browsers just do not have a window.open method this code will
          predictably error and terminate at this point in some environments,
          preventing any controlled degradation/fall-back. In the absence of a
          window.open function a reasonable fall-back option would be to navigate
          the current browser window to show the image that it intended to be
          shown in the pop-up. To do that you would need to test for the presence
          of the window.open function and branch the code if it is not present.
          Unfortunately, Pocket IE errors if you attempt to test for the
          window.open function but as it does not implement window.open it was
          going to error if you called it untested, and at least you gain the
          fall-back option on other non-window.open browsers.
          [color=blue]
          > // Set the window opener
          > if ( popupWindow.ope ner == null ) {
          > popupWindow.ope ner = self;
          > }
          > popupWindow.foc us();[/color]

          The main problem faced (and almost always ignored) by any script that
          attempts to open a new window is the existence of pop-up blocking
          software and browser that restrict the use of pop-ups. If it was
          possible to determine at this point that the call to window.open had not
          resulted in an actual new window, or that that window was about to be
          closed by an external pop-up blocker, then the script could take the
          fall-back option of navigating the current window (instead of just
          giving the user the impression that the link/button was just broken).

          Unfortunately, pop-up blockers use such a range of divers approaches
          that it is probably impossible to cover all of the possibilities. Which
          probably explains why knowledgeable script authors who want to achieve
          this type of pop-up display of images reliably (or at least in a way
          that allows the script to know when and where it will fail and take some
          fall-back action) are more likely to use a DHTML based in-window pop-up.

          <snip>[color=blue]
          >popupContent += "\n<body style='margin: 0px; padding: 0px;'>"
          >// Need to make sure the <body> has no padding
          > or margin or the image will be off-kilter[/color]
          <snip>

          Opera browsers pace default padding on the HTML element rather than on
          the BODY.

          Richard.


          Comment

          • DB McGee

            #6
            Re: pop up script!?!

            Cool - lets see your solution!

            "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
            news:bn6n4g$c78 $1$830fa795@new s.demon.co.uk.. .[color=blue]
            > "DB McGee" <noreply@norepl y.com> wrote in message
            > news:DEilb.1639 $h61.216@news01 .bloor.is.net.c able.rogers.com ...
            > <snip>[color=green]
            > >Try this out (NOTE - you should probably store the javascript in a
            > >*.js file so you can reuse it). I tested this on IE6 and Mozilla 1.4.[/color]
            > <snip>[color=green]
            > > // See if we need to dynamically grab the Image width dimensions
            > > // if none were passed in the function
            > > if ( ImageWidth == '' || typeof( ImageWidth ) == "undefined" ) {
            > > // If no image width was passed - preload the image then grab
            > > // the width value from the preloaded image
            > > theImage = new Image();
            > > theImage.src = ImageSource;
            > > ImageWidth = theImage.width;
            > > }[/color]
            >
            > That is a very optimistic piece of code. Assuming that the Image
            > constructor is not a non-functional dummy (as on ICEbrowser 5), setting
            > the src will cause an asynchronous request to a server for the specified
            > file (assuming that it is not in the browser cache already). That will
            > take some time even on a fast connection, yet milliseconds (if that)
            > later you are reading the width value from the image object. Not all
            > Image object implementations transfer the dimensions of the image to the
            > width and height properties anyway but those that do will no know the
            > size of the image until the server at least starts to return it (it
            > would need at least the first 10 bytes for a GIF file to know the image
            > size).
            >
            > There are no truly cross-browser method of automatically determining the
            > size of an image from its file. Some of the download timing problems can
            > be avoided by using the Image.onload/abort/error events to attempt to
            > read the image size after it has arrived, but that still assumes that
            > the Image implementation will read that information from the file and
            > make it available on the Image object (and that the events will be
            > triggered properly).
            >
            > Probably the only truly reliable approach would be to have the script
            > directly passed the required dimensions for the image.
            >
            > <snip>[color=green]
            > > // I think this works in NS6+ & Mozilla )![/color]
            >
            > It says above that you tested on Mozilla so you should know that NA6+
            > and Mozilla will be using the default 640x480 values.
            >[color=green]
            > > if (document.all) {
            > > var xMax = screen.width;
            > > var yMax = screen.height;
            > > }
            > > else {
            > > if (document.layer s) {
            > > var xMax = window.outerWid th;
            > > var yMax = window.outerHei ght;
            > > }
            > > else {
            > > var xMax = 640;
            > > var yMax = 480;
            > > }
            > > }[/color]
            >
            > That block uses crazy logic, there is no relationship between a browser
            > having a document.all collection and a window.screen object, and there
            > is no relationship between the document.layers collection and
            > window.outerWin dth/Height. There is, however, a direct relationship
            > between the existence of window.screen in a browser and the existence of
            > window.screen. Similarly, knowing that - typeof outerWidth == 'number' -
            > would be a reasonable indicator that outerWidth/Height values where
            > available on the browser (though there are a number of browsers that
            > erroneously report the same values for outerWidth/Height as the
            > (apparently) correct values that they use for innerHeigh/Width).
            >
            > So a decision logic that goes:-
            >
            > if(typeof screen != 'undefined'){
            > // read screen object properties.
            > }else if(typeof outerWidth == 'number){
            > // use outerWidth and assume outerHeight for symmetry (or
            > explicitly test it).
            > }else{
            > //default action
            > }
            >
            > -would seem to exactly match the requirement of the preceding code while
            > requiring no unsupported inferences about the browser DOM.
            >
            > But the actions of this code are also questionable. The screen width and
            > height properties should almost never be preferred over the
            > availWidth/Height values as they (sometimes) take into account various
            > taskbars (the number, size and distribution of which cannot be assumed).
            > outerWidth/Heigh will only be related to the screen dimensions if the
            > browser window is maximised, which will almost never be the case on a
            > monitor bigger than 19 inches. And the defaults are bigger than the
            > entire screen size of most PDAs.
            >
            > Generally, trying to explicitly position a browser window is fraught
            > with problems. On Opera's MDI interface there is every possibility that
            > positioning a window based on the screen dimensions will place the
            > window out of site. On multi-monitor displays some set-ups will have the
            > new window positioned across screen boundaries (the one place that you
            > don't want it), while other may have the new window appearing on a
            > different monitor to the original browser window. Usually opening a new
            > window without explicit positioning will allow the browser to put the
            > new window in a position that it thinks makes sense, usually over the
            > existing window but slightly offset towards its centre. Which means that
            > the new window is going to be appearing in a position that reliably
            > allows the user to be aware of it.
            >
            > <snip>[color=green]
            > > /* Set the various features for the preview window -
            > > width, height, titlebar etc. */
            > > var popupFeatures =
            > > 'width=' + ImageWidth +
            > > ',height=' + ImageHeight +
            > > ',screenX=' + xOffset +
            > > ',screenY=' + yOffset +
            > > ',top=' + yOffset +
            > > ',left=' + xOffset[/color]
            >
            > Assuming that at this point the ImageWidth and ImageHeigth variables do
            > hold the dimensions of the image, you are making no allowance for window
            > chrome. That is not surprising as it is extremely difficult to determine
            > the size and distribution of window chrome, and assuming standard values
            > cannot be valid across OSs and are almost always alterable under user
            > preferences anyway.
            >
            > However, I observe that you are not providing specification for
            > resizable or scrollbars, causing then to default to off. Removing these
            > features places the onus on the script to ensure that the new window
            > will be able to display all of its contents under _all_ circumstances
            > because if the script gets this detail wrong there will be nothing that
            > the user can do to access the content. As it stands this script does not
            > even come close to achieving that level of reliability in its sizing
            > decisions. But then I have never seen a script that does cover all of
            > the possibilities (which leads me to suspect that it is just not
            > possible to do so), which means that leaving the new window at least
            > sizable and probably scrollable is probably the best approach towards
            > addressing the issues of window pre-sizing.
            >[color=green]
            > > /*
            > > 4. CREATE AND OPEN THE POPUP WINDOW
            > > */
            > >
            > > popupWindow = window.open('', PopupTitle,popu pFeatures);[/color]
            >
            > As some browsers just do not have a window.open method this code will
            > predictably error and terminate at this point in some environments,
            > preventing any controlled degradation/fall-back. In the absence of a
            > window.open function a reasonable fall-back option would be to navigate
            > the current browser window to show the image that it intended to be
            > shown in the pop-up. To do that you would need to test for the presence
            > of the window.open function and branch the code if it is not present.
            > Unfortunately, Pocket IE errors if you attempt to test for the
            > window.open function but as it does not implement window.open it was
            > going to error if you called it untested, and at least you gain the
            > fall-back option on other non-window.open browsers.
            >[color=green]
            > > // Set the window opener
            > > if ( popupWindow.ope ner == null ) {
            > > popupWindow.ope ner = self;
            > > }
            > > popupWindow.foc us();[/color]
            >
            > The main problem faced (and almost always ignored) by any script that
            > attempts to open a new window is the existence of pop-up blocking
            > software and browser that restrict the use of pop-ups. If it was
            > possible to determine at this point that the call to window.open had not
            > resulted in an actual new window, or that that window was about to be
            > closed by an external pop-up blocker, then the script could take the
            > fall-back option of navigating the current window (instead of just
            > giving the user the impression that the link/button was just broken).
            >
            > Unfortunately, pop-up blockers use such a range of divers approaches
            > that it is probably impossible to cover all of the possibilities. Which
            > probably explains why knowledgeable script authors who want to achieve
            > this type of pop-up display of images reliably (or at least in a way
            > that allows the script to know when and where it will fail and take some
            > fall-back action) are more likely to use a DHTML based in-window pop-up.
            >
            > <snip>[color=green]
            > >popupContent += "\n<body style='margin: 0px; padding: 0px;'>"
            > >// Need to make sure the <body> has no padding
            > > or margin or the image will be off-kilter[/color]
            > <snip>
            >
            > Opera browsers pace default padding on the HTML element rather than on
            > the BODY.
            >
            > Richard.
            >
            >[/color]


            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: pop up script!?!

              DB McGee wrote:
              [color=blue]
              > Cool - lets see your solution![/color]

              Let's see your brain. I doubt there is one:
              [color=blue]
              > [213 lines of fullquote][/color]


              PointedEars

              Comment

              • Richard Cornford

                #8
                Re: pop up script!?!

                "DB McGee" <noreply@norepl y.com> wrote in message
                news:rmDlb.2423 97$ko%.221713@n ews04.bloor.is. net.cable.roger s.com...[color=blue]
                >Cool - lets see your solution![/color]

                Given that I said:-

                <snip>[color=blue][color=green]
                >>... leads me to suspect that it is just not possible to do so ...[/color][/color]

                - and:-

                <snip>[color=blue][color=green]
                >>... probably impossible to cover all of the possibilities. ...[/color][/color]

                - I assume you are not referring to my solution to a generalised script
                for displaying images in pop-up windows, but instead are referring to:-

                <snip>[color=blue][color=green]
                >>... use a DHTML based in-window pop-up.[/color][/color]
                <snip>

                I must say I admire the speed and efficiency of your archive searching
                techniques. While I know that I have posted (more or less) detail on
                every aspect of creating an image displaying in-window pop-up at some
                time, I could not remember if I had ever posted a complete example, and
                the prospect of searching the groups.google.c om archives to determine
                that one way or the other is somewhat daunting. Still, you have saved me
                the effort of checking. But even if I had the result would not have been
                much use to the OP as any example I had created would have been fairly
                tightly integrated with the HTML DOM it was scripting in order to
                achiever reliable fall-back (particularly in the face of JavaScript
                non-availability). I don't believe this is an area that lends itself to
                generalised cut-n-paste solutions.

                There are people (including myself) who's reaction to having issues with
                their scripts pointed out to them is to take those points as indicating
                aspects of a script that need improving, possibly even responding by
                posting a better version with the issues addressed. If I had not adopted
                that attitude myself I would be no better at browser scripting now than
                I was 18 months ago, and, although 18 months ago I believed that I was
                good at JavaScript authoring, in retrospect I can see that I was utterly
                mistaken in that opinion.

                If you did respond to the points that I raised with an improved
                generalised pop-up window script that addressed the issues (particularly
                the unpredictable unreliability that is introduced by pop-up blocking
                software) then the result would be a major contribution to the browser
                scripting world. It would allow the people who insist on using pop-ups
                regardless of the reliability to pull their heads out of the sand and
                get on with addressing the remaining accessibility (and desirability)
                issues.

                It was attempting to address those pop-up reliability issues that
                convinced me that there was no adequate strategy that could be applied
                to the problem and convinced me that it was better to look in other
                directions for that type of functionality. But I could still be wrong,
                and if so I would love to see the code that did it.

                Richard.


                Comment

                • DB McGee

                  #9
                  Re: pop up script!?!

                  Was the insult really needed? Must've read this before your morning cup of
                  coffee?

                  Obviously, my solution was lacking and there are people clearly more able
                  and skilled than I in this newsgroup. I just figured that if someone can
                  take the time to deconstruct a response, they should at least try to provide
                  a solution to the question asked.

                  For someone of Mr. Cornford obvious talents, this should be a fairly trivial
                  task. I'm anxious to see a solution that covers the various issues raised
                  by Mr. Cornford in his response to my solution. I'm sure others would as
                  well. That would be far more illuminating to the archival record of the
                  original message in this thread than simply slinging insults around.


                  "Thomas 'PointedEars' Lahn" <PointedEars@we b.de> wrote in message
                  news:3F9716A6.4 000803@PointedE ars.de...[color=blue]
                  > DB McGee wrote:
                  >[color=green]
                  > > Cool - lets see your solution![/color]
                  >
                  > Let's see your brain. I doubt there is one:
                  >[color=green]
                  > > [213 lines of fullquote][/color]
                  >
                  >
                  > PointedEars
                  >[/color]


                  Comment

                  • Thomas 'PointedEars' Lahn

                    #10
                    Re: pop up script!?!

                    DB McGee wrote:
                    [color=blue]
                    > Was the insult really needed? [...]
                    >
                    >
                    > [nuked appended fullquote][/color]
                    ^^^^^^^^^^^^^^^ ^^^
                    [_] You understood.

                    BTW: If you would have provided an e-mail address as RFC 1036 and 2822
                    specify, I would have replied in private, not in the public newsgroup.


                    PointedEars

                    Comment

                    • Dr John Stockton

                      #11
                      Re: pop up script!?!

                      JRS: In article <kQYlb.26839$h6 1.22167@news01. bloor.is.net.ca ble.rogers
                      ..com>, seen in news:comp.lang. javascript, DB McGee <noreply@norepl y.com>
                      posted at Thu, 23 Oct 2003 22:43:28 :-
                      [color=blue]
                      >Was the insult really needed?[/color]

                      Since you re-posted over 200 lines of material to add a single line :
                      Yes, indeed it was.

                      Before writing to a newsgroup, you should seek and read its FAQ. That
                      is a useful precaution against giving the appearance of thoughtlessness
                      or ignorance. Most FAQs, including ours, cite and/or describe the
                      proper construction of news articles, including replies.

                      But, PE, such remonstrations should always be accompanied by a link to
                      educational material.

                      --
                      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                      <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                      Comment

                      • Richard Cornford

                        #12
                        Re: pop up script!?!

                        "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
                        news:bn8meg$6t8 $1$8300dec7@new s.demon.co.uk.. .[color=blue][color=green]
                        >>Cool - lets see your solution![/color][/color]
                        <snip>[color=blue]
                        >... , but instead are referring to:-
                        >
                        ><snip>[color=green][color=darkred]
                        >>>... use a DHTML based in-window pop-up.[/color][/color][/color]
                        <snip>[color=blue]
                        >..., I could not remember if I had ever posted a complete example, ...[/color]
                        <snip>

                        There is not much point posting the code of an example without the
                        images, so I have put an example on-line:-

                        <URL:
                        http://www.litotes.demon.co.uk/examp...ndowPopUp.html >

                        - (it may not be there for more than a week or so.)

                        Richard.


                        Comment

                        Working...