Web Analytics Made Easy -
StatCounter Popup Image Viewer - CodingForum

Announcement

Collapse
No announcement yet.

Popup Image Viewer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Popup Image Viewer

    I wrote this a long time ago and it seems to get posted in the forums quite a bit so I figured I post it here for easy reference:

    Code:
    <script language="Javascript" type="text/javascript">
    <!--//
    function imageView(imgFile,imgTitle,imgWidth,imgHeight,winPosX,winPosY){ 
    preview = window.open("","","resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width="+imgWidth+",height="+imgHeight+",left="+winPosX+",top="+winPosY+"");
    preview.document.write('<html><head><title>'+imgTitle+' - Click to close - <\/title><\/head>'
    +'<body onBlur="self.focus();" marginWidth="0" marginHeight="0" topmargin="0" leftmargin="0">'
    +'<center>'
    +'<a href="java script:self.close()">'
    +'<img border="0" alt="Image loading please wait...." src="'+imgFile+'" width="'+imgWidth+'" height="'+imgHeight+'">'
    +'<\/a><\/center>'
    +'<\/body><\/html>');
    preview.document.close();
    }
    //-->
    </script>

    <!--// Parameter list as follows:
    Image File
    Title of Image
    Width of Image
    Height of Image
    Window Position X coordinate
    Window Position Y coordinate
    //-->



    Example of use:

    Code:
    <a href="javascript:imageView('images/australia08.jpg','Australian Limestone Desert',427,277,50,50)">
    <img src="images/australia08thumb.jpg" width="84" height="55" border="0" alt="Click for larger image"></a>
    If you want to use this download the attached text file instead of copying and pasting from the screen here. The forum keeps putting spaces in the coding when copying and pasting causing the script to have an error.
    Last edited by Spookster; Sep 22, 2002, 12:10 PM.
    Spookster
    CodingForum Supreme Overlord
    All Hail Spookster

  • #2
    I'm glad you put this here, as I've had to copy it from my pages numerous times for the forums.

    One important note:
    While you can take the <script> portion and put it in an external JS file for use/calling on multiple pages, N6 blanks...and subsequently won't complete the function. Therefore, for cross-browser usage, the <script> part needs to be put in the <head> of each and every page upon which you want to use it.

    Thanks Spookster!
    Gordo
    "In the End, we will remember not the words of our enemies, but the silence of our friends."
    - Martin Luther King Jr. (1929-1968)

    Comment


    • #3
      Spookster -

      Your code is exactly what I was looking for, except there seems to be a problem when I use it. The script activates, but cannot find the image (checked image path of course, and made sure the image is THERE of course). Tried several things, but all I get is "URL not found on this server"

      Sorry to be so dense, I'm just a Javascript newbie. Maybe there is something basic I screwed up (I cut and pasted the code, but maybe something got screwed along the way). Frustrating, and probably a simple problem. Any help would be appreciated!

      Comment


      • #4
        Spookster -

        I found my error. Thanks for making me look twice!!

        The SoupNazi @ http://www.ChefOnTheEdge.com

        Comment


        • #5
          Nice code i had wrote something simalar and submited it here


          It does the same thing as yours i think or very simalar.

          Nice to see other people think pop up image thumbs are a good thing. hehe.

          T.G.O.

          Comment


          • #6
            Popup Image Viewer File

            Here is the attachment. Couldn't seem to put it in my original post
            Attached Files
            Spookster
            CodingForum Supreme Overlord
            All Hail Spookster

            Comment

            Working...
            X