Web Analytics Made Easy -
StatCounter Popup Image Viewer - CodingForum


No announcement yet.

Popup Image Viewer

  • 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:

    <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">'
    +'<a href="java script:self.close()">'
    +'<img border="0" alt="Image loading please wait...." src="'+imgFile+'" width="'+imgWidth+'" height="'+imgHeight+'">'

    <!--// 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:

    <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.
    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!
    "In the End, we will remember not the words of our enemies, but the silence of our friends."
    - Martin Luther King Jr. (1929-1968)


    • #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!


      • #4
        Spookster -

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

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


        • #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.



          • #6
            Popup Image Viewer File

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