Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question ViewImage JavaScript Not Working in IE8

    The ViewImage JavaScript is an important part of my web site. I use it to display larger images of products, difinitions of features and finish sample photos. These images are different sizes. The size of the window is specified in the link to the image. The window remains open until the user closes it. It has fuctioned properly in all earlier IE versions.

    With IE8 the window opens at the correct size, but does not load the image, and then immediately re-closes, then opens again and this continues in a flashing sequence! The only way to stop it is to back out of the page.

    This is the part of the Script posted in the Header:
    [CODE]


    <SCRIPT LANGUAGE="JavaScript">


    <!-- Begin
    function ViewImage(ifile,ix,iy,ititle) {
    var win;
    var sWidth;
    var sHeight;
    var NS = (document.layers) ? 1 : 0;
    win = window.open("","imageviewer","width="+ix+",height="+iy+",menubar=no,toolbar=no");
    if (NS) {
    sWidth = win.innerWidth;
    sHeight = win.innerHeight;
    } else {
    sWidth = win.document.body.clientWidth;
    sHeight = win.document.body.clientHeight;
    }
    if(sWidth!=ix || sHeight!=iy) {
    win.close();
    setTimeout("ViewImage('"+ifile+"',"+ix+","+iy+",'"+ititle+"')", 250);
    return;
    }
    win.document.open();
    win.document.write("<html><head><title>"+ititle+"</title>");
    win.document.write("</head><body>");
    win.document.write('<div style="position:absolute;width:'+ix+'px;height:'+iy+'px;left:0px;top:0px">');
    win.document.write("<img src="+ifile+"></div></body></html>");
    win.document.close();
    }
    // End -->
    </script>

    This is an example of the link code that activates it and is posted in the body of the page:
    [CODE]


    <a href="javascript:ViewImage('../cat/20530.jpg',456,351,'20530 Product')"><img src="../images/20530p.jpg" alt="20530 Product"></a>

    Any help to make this code workable in IE8 would greatly be appreciated. I am at my wits end!

    Thanks a bunch!

    Scout720

  • #2
    Banned
    Join Date
    Nov 2008
    Location
    not found
    Posts
    284
    Thanks
    0
    Thanked 53 Times in 51 Posts
    Code:
    if(sWidth!=ix || sHeight!=iy) {
    win.close();
    setTimeout("ViewImage('"+ifile+"',"+ix+","+iy+",'"+ititle+"')", 250);
    return;
    }
    This code is causing the closure and reopening of the window if its reported dimensions don't match those specified. This would probably happen under a strict doctype, but I don't see the rationale and I would remove it.

    Also the links should be constructed like this:

    Code:
    <a href='../cat/20530.jpg' onclick="ViewImage('../cat/20530.jpg',456,351,'20530 Product');return false"><img src="../images/20530p.jpg" alt="20530 Product"></a>

  • Users who have thanked randomuser773 for this post:

    Scout720 (07-20-2009)

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up randomuser773 - You ROCK!

    Removing that part of the code seems to have done the trick! Even the old links work without the suggested changes which is great for me! There are thousands of them in the database which would need to be modified.

    Thank you so much for responding to my call for help! What a relief!

    I really appreciate it!

    Scout720


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •