Posted by: Terry Nederveld | July 2, 2009

Lytebox and Internet Explorer 8

If you haven’t noticed, lytebox doesn’t work properly with IE8. The background overlay and the border color of the popup do not show. I have read a few blogs about how people are changing the cascading style sheet (CSS), in my search I found it wasn’t the CSS that was the issue. It is the actual script. Here is what I did to get it working properly.

The issue originated from this line:

this .ie = (document.all && !window.opera) ? true : false;

Here is how I got it to work:

this .ie = (document.all && !window.opera) ? checkVersion() : false;

I added the “checkVerzion()” function right before the LyteBox.prototype.initialize function.

function checkVersion() {
         if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
                  var ieversion = new Number(RegExp.$1)
                  if (ieversion >= 8 )
                           return false;
                  else if (ieversion < 8 )
                           return true;
         }
         return false;
}

After adding that code to the lytebox.js file, the LyteBox popup works properly in IE8 and continued working properly in all other tested browsers (IE7, Firefox 3.0.11, Safari 4.0, Chrome 2).

Amended July 7, 2009:

I had a person ask for the source of the JavaScript file, so I posted it on my SkyDrive. You can download it from here:

http://cid-4965eef15ed4a439.skydrive.live.com/self.aspx/.Public/LyteBox.zip

Amended February 24, 2011:

We now have a community project up on GitHub. See my blog post at:

https://nederveld.wordpress.com/2011/02/24/lytebox-take-over/


Responses

  1. Thanks for this simple fix, it works like a charm!

  2. Perfect!

  3. I’ve done the corrections as you have posted although I’ve still got the problem with Lytebox in IE8 – loads then closes straight away!?

    Do you have a copy of the new lytebox.js source?

    Many thanks in advance if you can help further! 🙂

    J

  4. Thanks for that Terry! It works fine when on it’s own, although I have also lightbox working on the same page as lytebox. This seems to be giving me the problem again. Perhaps I can’t have both apps on the same page? I’ll just try and go with Lytebox, don’t see why I need both anyway!! I’ll post back to see if that sorts the issue!

    Thanks, J

    • Still doens’t work – its the IFRAME option that keeps closing, everything else works fine.

      + OPTIONS

      Done exactly as Lytebox docs tell you to do but still closes upon opening!! ?? any ideas?

      • The link above is supposed to show as the following so you can see:

        [ a href=”hoods_poptions.php” rel=”lyteframe” title=”Dutch Hood Options” class=”button” id=”button” rev=”width: 670px; height: 420px; scrolling: no;”]+ OPTIONS[/a]

        • I will look at the lyteframe stuff today sometime and let you know if I find anything.

          • Thanks Terry, i’ve put a temporary modal on at the moment so visitors can actually see whats trying to be opened!

            • I have tested it here and did not run into any issues with the lyteframe. What does the page “hoods_poptions.php” have on it? That may be where the issue is coming from.

            • Do you have the lytebox.js file included on the page you’re opening in the iframe? I found that lytebox didn’t like to be included on pages that are being opened in the iframe lytebox, but removing it solved the issue for me.

              (If you need a lytebox iframe opening within a lytebox iframe, that’s probably a whole other can of worms 🙂

  5. Terry,

    Your fix is nothing less than a gift from heaven.

    Thank you.

  6. Hi Terry, Thanks a lot for your fix. It works great on IE8 now.

    However, i tried Lytebox in Google Chrome today and the lytebox links are all opening in a separate page, not in the lytebox window.

    Do you have any idea why?

    Link Here : http://www.thru-my-lens.info/Nature/Wildlife/

    • I think the problem is coming from the rel=”lytebox-wild” try changing it to rel=”lytebox[wild]”. Let me know if that works.

      Thanks, Terry

      • Hi.. thanks a lot for looking. I changed that, but its still has the same problem. I have a lyteframe set up in that page a well, which is behaving the same.(The “Slideshow” Link)

        I checked in Google Chrome’s Inspector and it giving the following error: http://www.thru-my-lens.info/rw_common/themes/thru_my_lens/css/lytebox/lytebox.js:200 Uncaught TypeError: Cannot call method ‘getElementsByTagName’ of undefined

        I am not proficient in Javascript, so couldn’t make any head or tail of this error.

        Would really appreciate if you could give me any ideas.

        Thanks

        • I will take a deeper look into it later tonight and let you know if I see anything.

        • Ok, Ray, try this. Down in the lytebox.js file you will see LyteBox.prototype.checkFrame = function() { inside that function try changing the IF statement to look like this:

          if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length > 0)) {

          Thanks, let me know if that helps.
          Terry.

          • A Big Thank You to you Terry… It works now in all the browsers. Thanks a lot for taking the time and looking into the code. You are a great help!!

            One thing, is it a problem with lytebox or a problem with my specific settings?

            Thanks Again.
            Ray

            • Something with the rating & comment scripts were causing an issue, if you remove those and change the lytebox.js file back to the other way it will work. I figured you didn’t want to loose that abilty, so I tracked down the differences and made the modification to the javascript for the lytebox. Just remember if the developer for LyteBox puts out an updated version and you want to update yours remember the modifications you have made to the file incase the new version doesn’t work for you again.

              Thanks, Terry.

              • Ok, got it… Thanks a lot for your efforts 🙂

  7. I’m having a hard time with different browsers as relates to the size of the image. It works like a charm in Chrome and Safari, but in Opera, FF, and IE8, the viewer gets only as big as the iframe the thumbnails are in. As a result, the ‘larger’ image ends up smaller than the thumbnail. Oh, and btw, I have to use iframe; my client demanded it.

    You seem like a kind soul. Even if you’re not able to help, you’ve done plenty of good for people. Thank you.

    Adam

    • I should probably have put the page in question 😐

      http://www.frartexchange.com/gallery_new_frame.html

      • I will try an take a look at it in a bit. I am sure it relates to the fact that the page is in an iFrame. I will see what I can come up with.

        Thanks, Terry

        • Adam, I took a look and I believe if you just add an id=”whateverName” on the iframe it will start working properly. If you want the correct theme to show up in IE you will want to apply the fix in this article to the lytebox.js file that is linked in the page that the actual images are on (frame_1.htm).

          Let me know if this works for you.
          Terry

      • Your photos for show are within a small IFRAME itself, so it appears that the lytbox is displaying the images in a size so that they will fit within the IFRAME, not the parent document. I’m sure Terry will know more though!

        @ Terry – i’m going to change the page the lytframe loads to see if that makes any difference in regards to my issue!

        • Let me know what you find.

          Thanks, Terry.

          • Hi Terry,

            I changed the a href option to a blank file which opened without any issues at all. I removed several <link rels and <scripts associated with lytbox in the hoods_poptions.php page and it now loads and stays on screen!! Thanks for your patience and help on this matter Terry, much appreciated!

            Jamie

  8. Hi,
    the fix works correct in IE8 only if i check the browser “compatible mode”. Otherwise lytebox does not show navigation pictures and the background does not get dark.
    Is this a feature or a bug?
    Thanks, HM.

    • IE8 is a more standardized browser then previous versions so in order for the lytebox control to work now in IE8 non-compatible mode you will need to make the changes describe above to the javascript source file. If you have any issues, post back here and I or someone watching this post will try to help as much as possible.

      Thanks, Terry.

  9. another interesting finding: Here – http://www.hzs-kvk.cz/r_foto.php?mh=1&ml=11 – I use the same lytebox and it works in IE8 fine.
    but another problem: patched lytebox is very very slow in IE8.

    • I am not sure what is causing the issue on the one page but not the other. The only thing that I can think of is that possibly malformed HTML, CSS, etc. could be causing the issue on the one page. If it is working in one area of the site but not another, it leads me more to think it’s with that specific page not the JavaScript source. Hope this helps, let me know if we can be of further assistance.

      • OK, I will take a look again on the whole code. But one more question – is any possibility to speed up opening lytebox frame in IE8 – it is very slow now.
        Thanks, HM

        • Yes, you can control the speed. In the lytebox.js file there is a property called this.resizeSpeed, according to the comment next to it. The speed is controlled with a 1 through 10, the lower the number the slower it is. Try changing that in order to increase or decrease the speed.

          Thanks, Terry.

          • I have changed this.resizeSpeed parameter, but the speed of opening lytebox frame stays the same even if i use 1 or 10 in the parameter (speed is OK in FF, in IE7 is not so fast as in FF, but its fast enough, but in IE8 its very slow). 😦
            Thanks, HM.

            • Now its OK with the animation speed. I have disabled animation as a whole (this.doAnimations= false;) and this is what i need. Tanks for help, HM

  10. Thanks for posting the fix, Terry! By the way, to make the checkVersion() function a little simpler, you can replace this:

    if (ieversion >= 8 )
    return false;
    else if (ieversion < 8 )
    return true;

    with this:

    return (ieversion < 8);

    • Thanks K, I will make the change to the post and zip file contents as soon as I can.

    • Or you may want to get rid of the CheckVersion function altogether and use:

      this.ie = (document.all && !window.opera) ? !(/MSIE 8/.test(navigator.userAgent)) : false;

      • Good idea, but that doesn’t account for future IE versions. Maybe you could use this instead:

        this.ie = (document.all && !window.opera) ? /MSIE [3-7]/.test(navigator.userAgent) : false;

  11. There are many code post but few are helpful and to the point… Thank for being apart of the few..

    Developer7

  12. I would like to know if anyone is having issues with IE6. The buttons and the background don’t work there. I did make it work in IE8 with the explanations given above.

    Thanks

    • Do you have a page that we can view the issue you are talking about? As far as I know (which I don’t have IE6 on any machines) there is not an issue. Sometimes other scripts on the page cause issues with lytebox. Let us know if you have a viewable page where it is happening.

      Thanks, Terry

  13. Hello Terry,

    I don’t want to take any credit from you for the great work that you have done trying to resolve the issue of Lytebox on IE8, but this is what I have found out:

    To respond to your unawareness about IE6, the same site for Lytebox says about the different browsers capable to use Lytebox. IE6 is not mentioned there.
    • IE 5.01 SP2 – The fade effect does not work, but the background is darkened (completely).
    • IE 5.5 SP2 – No known issues.
    • IE 7.0 – No known issues.
    • Opera 9.23 – No known issues.
    • Firefox 1.5+ – No known issues, of course.
    In IE6 the images don’t appear and neither the background.
    After playing for a while trying to fix this, I decided to set the ‘A’ tags styles on the JS file, but later I removed my changes because I was able to look on the CSS a little closer and play around with those ‘A’ tags. This is what I changed on the CSS for the ‘A’ tags:
    From this: #lbClose.grey { background: url(../images/close_grey.png) no-repeat;
    To this: .grey #lbClose{ background: url(../images/close_grey.png) no-repeat; }

    IE6 likes to have the class selector first and the ID selector next. I tried the same with IE8 by removing the checkVersion() and leave it but like it was to true.

    But not all worked the way I was expecting. The background color was not working on IE6, so I did the same as the A tags, but for some reasons the DIV tags stopped working when I made the change. Ex:

    .grey #lbOverlay { background-color: #000000; }

    This breaks in IE8 and probably all IE versions. To fix this problem, I moved all the styles settings to the JS file. At the end of the LyteBox.prototype.initialize = function(), I include an if statement to set all these DIVS depending on the theme. Ex:

    if (this.theme == ‘gold’){
    this.doc.getElementById(‘lbOverlay’).style.background=”#011D50″;
    this.doc.getElementById(‘lbDetailsData’).style.color=”#01379E”;
    this.doc.getElementById(‘lbOuterContainer’).style.border =”3px solid #5F89D8″;
    this.doc.getElementById(‘lbDetailsContainer’).style.border=”3px solid #5F89D8 “;
    this.doc.getElementById(‘lbDetailsContainer’).style.borderTop=”none”;
    }else if(this.theme == ‘grey’){
    ….

    So after adding this on the JS file and comment out these settings on the CSS file, I was able to make the lytebox on all IE versions and Mozilla.

    I wish I can play more to set the DIV’S style on the CSS rather than the JS, but it seems that DIV tags behave different that A tags. If anyone makes it to work, let me know.

    David

  14. Thanks for the help! It fixed the PRE, NEXT, CLOSE problem but my entire gallery loads each picture so slow!! SOOOO SLOW!

    I can do this: this.doAnimations= false;
    but I want the animation! But I just want it at a better speed. Any help on this would be fantastic!!

  15. BTW, changing the speed doesn’t work either. It’s still SOOOO SLOW!!!

    • Sarina, if you are using IE8, click the compability view button like somebody already mentioned in the previous notes. That helped mine some.

      David

  16. Hi Terry,

    i am just creting a site with lytebox and i also have a IE 6 problem. You can see the site here: http://www.cafetindelsur.de/eltaller/analia_canal-feijoo.html
    Btw, thy for the IE8 fix.

    Saludos de Tucuman, Argentina, Michael

    • What is the issue you are having with IE6. I have loaded a VHD of XP with IE6 and the lytebox on the page you supplied seems to be working fine.

      Thanks, Terry

  17. Hello Terry,

    the close and play button and the grey overlay dont show up. But maybe its becasue i use IE6 in Crossover for Mac.
    You should see the buttons in any other browser.
    After your fix the IE6 is the only browser which makes problems-

    Saludos, Michael

    • I don’t know how well you will be able to see this, but I took a screen shot of the VHD. You can view it at this link: https://nederveld.wordpress.com/?attachment_id=67

    • Michael,

      have you read and tried the the other workaround that I did for IE6?

      David

  18. Hello Terry

    gives me a error message, not found but you can send it me by mail.

  19. Hello Terry, that losk fine. Seams it is a IE& in Crossover problem.
    And thx too David too but it seams it works.

    Thank you very much for your time.

    Michael

  20. […] Nicméně se našel šikovný človíček, který tuto webovou galerii ještě na chvilku oživil. […]

  21. hi everyone,

    thx to terry for all the workarounds, but i still got the lyteframe-problem @ IE 8 & actual ff.

    bind the lytebox.js @ the called doc doesn’t help too.
    any ideas ?

    thx

    • ted72,

      Do you have a link to where we can see the problem actually happening?

      Thanks, Terry

      • yes, http://www.qdorf.de.. in the middle you got pictures – they work fine. but sometimes you got “mehr..” buttons, they don’t work..

        • hm.. no ideas ?

          • Sorry, got busy around here. I will have to look at it later today/tonight and get back with you. Has anyone else had a chance to look ino the issue he is having?

            Thanks, Terry

            • I didn’t see an area where it wasn’t working. Can you give us more details?

              Thanks, Terry

  22. Amazing!
    Thanks a lot for this great solutions!

  23. I’m having BIG issues with Lytebox in Mozilla v3.5.2. when calling it from an iFRAME.

    I set it up correctly, and when I click the image in the iframe it pops up on the whole page like it should, but no photos appear. I tried it on IE and it worked fine.

    Anyone have an idea what might be wrong?

    Thanks!

  24. Thanks, for the nice fix. It works also under ie6.

  25. I actually figured it out. But can’t remember what I did.

    Another thing to check is to make sure if you’re using lytebox in IE 6.0 in iFrames that the page starts with:

    Otherwise it won’t process the photos correctly

  26. starts with HTML 4.01 Strict. DOCTYPE

  27. Hi Terry,

    Unfortunately your patch doesnt seem to be working. I downloaded the files from your sky drive and used them instead of the originals – but alas still nothing.

    It works fine in safari and firefox, just not internet explorer.

    http://www.resortreport.com.au/test2/collection2.html

  28. I have fixed the load problem by playing around with the script but I’m now getting an error when my flash file loads on my 360 panos but only on ie7 and ie8.

    I also would like to display a message when users don’t have the correct version of flash.
    can someone help?!!
    sample site
    http://www.virtualgta.com/0909/PZ/35Sutcliff/Site/Main.html

  29. Hi Terry,
    After one morning around this stupid issue, ’cause i already put it work in IE8 without this fix (http://www.sabrosa.pt/media/galeria_fotos/index.php?action=getFotosCategoria&id=24), i updated lytebox with this fix and now works like a charm in another project 😉
    Tested in IE 8, Opera 10.0, Chrome 2.0 and Firefox 3.5.2

    Works like a charm,
    Thanxs

  30. Hi Terry; I am having issues with I.E. not graying out and no close button showing.

    View in I.E. 8.

    http://pioneerdoctor.com/ProductPage_Detail_test.cfm?ProductPricingID=847

    Any help would be appreciated, Thanks!

    • Have you tried pointing directly to the image and using lytebox instead of lyteframe? I will keep digging around and see if I can come up with anything else.

      Thanks, Terry

  31. No I have not, I am trying to include some dynamic text underneath the image. Can that be done with LyteBox? I am so bummed, I really hate i.e. 8 Any help would be awesome. Thanks!

    • Eric,

      We don’t have to say I hate that because something it is not working like it should! When I found Lytebox, I thought I found something that works and easy to use, but in my opinion it was not compatible with all IE versions. What it’s not compatible is the CSS file. Some versions allow using some type of selectors for classes, IDs, and objects.

      For instance, the css for one button is like this:
      #lbClose.grey {background: url(../images/close_grey.png) no-repeat;}

      When I changed things around like this, it worked:
      .grey #lbClose{ background: url(../images/close_grey.png) no-repeat;}

      It seems like IE6 needs to have the class selector first and the ID selector next.

      I don’t fully understand CSS syntax, but this is what I found out.

      I would like to read my input that I wrote here on July 31 and give it a try.

      David

  32. Thanks David, Terry.

    I have found this post and tweaked the CSS as it instructs you to do and it works in Safari, I.E. 8 and Firefox. I am not able to test in Chrome until I get home. For some reason Chrome will not work on my laptop. Cheers to all of you for testing and making fixes. I think Lyte box rocks.

    • Hi Eric,

      What post did you find? Could you share the link?

      David

  33. oops, I planned on doing that, sorry.

    http://guildlaunch.blogspot.com/2009/05/making-lytebox-work-in-ie8-close.html

    -E

  34. Does anyone know if there is a conflict between lytebox and AllWebMenus? I have a site I am working on that works locally, but when uploaded and browsed remotely, the lytebox modal windows don’t work, I just get reply windows.

    http://www.apexemb.net/new/football_applique.html

  35. Never mind, solved. Syntax error. It doesn’t like the css file being out the script directory for some reason.

  36. Very GOOD Job !!

    great !

    I put a comment in the script for link your page 😉

  37. Thanx!

  38. Thanks for sharing the fix, I discovered the true root of the issue myself as well and prefered to not bandaid fix it with CSS changes, you’ve just saved me some time and javascript pain.

    Cheers

  39. Excusa me, but I have a answer. I have made a web and i have used LyteBox. I have used a iframe in the main page. I have photos in the iframe and I want to load it in the main page, out of the iframe. It run in IE6 and IE7, but it don’t run in IE8 and Firefox 3.

    The link is http://www.nazarenodegranada/sede/sede.html

    Please, help me.

    Thank you.

  40. Thank you for saving a day of my lifetime.

  41. Thank you soooo much for sharing it!!

  42. Hi

    The Lytebox it’s working, thanks, but the speed it’s to slow.

    Any solution?

    Thanks

    • From my experience, transition between images is slow because the original image you link to is to large. Reduce its size speeds things up.

  43. GREAT !! THX A LOT

  44. Thank you so much!

  45. Thanks for your reply.

    I forgot to mention that the problem is the speed of the animation, not from the transition.

    You can see in my page with iframes:

    http://www.elesandemai.net63.net

    If you use firefox, click in the shadow, otherwise in the photo. Some bugs to fix.

    Regards

  46. Thanks for posting this fix – you have saved me a lot of time.

    I am very grateful.

    Vee

  47. awesome post

    competitive intelligence

  48. On this website it’s not working correctly in IE8. The same issues…no close…no prev…no next…and the worst no overlay. I’ve got all the fixes you’ve explained and it is still not working.

    Maybe you can figure it out. I’m stumped…..

    Here’s the Javascript:
    http://www.brightimagesvideo.com/tempweb/darkops/lyteboxie1.js

    Here’s the CSS:
    http://www.brightimagesvideo.com/tempweb/darkops/lyteboxie.css

  49. It seems I still have these problems in IE8 even after the fix has been added. The worst of the problems I think is not having the overlay show. I’ve been trying to figure out what could be wrong???

    The Website:
    http://www.brightimagesvideo.com/tempweb/darkops/reviews.html

    JS:
    http://www.brightimagesvideo.com/tempweb/darkops/lyteboxie1.js

    CSS:
    http://www.brightimagesvideo.com/tempweb/darkops/lyteboxie.css

  50. Thanks for fixing this, was scratching my head all morning trying to figure it out before i found this solution.

  51. Ok, I have to ask a different issue, always about Lytebox. The thing is, sometimes it delays to load the page, for example when there is a slow connection, or whatever similar very few times… it happens that Lytebox does not open when clicking the links, instead of it , the links load in same page or a new page (classic function when working with simple linnks without lytebox) …

    So… is there anyway to make it work always ?

  52. Would this fix also work with the js i downloaded for use on iweb?

  53. thanks! It really works!

    I’ll bookmark this page now! just in case 😀

  54. Thanks mate, great fix!

  55. Thanks man!

    This is the $#$% to correct this nightmare!

    /Per

  56. To fix the iframe problem in ie8, just add a name to the iframe in the parent page

  57. nice, cheers

  58. […] and found that there is a compatibility issue with IE8 that needs to be addressed.  I found a solution by Terry Nederveld that entails downloading updated Lytebox source code, which resolved issues on […]

  59. […] Odpowiedź na pierwszy problem: http://guildlaunch.blogspot.com/2009/05/making-lytebox-work-in-ie8-close.html, na drugi: https://nederveld.wordpress.com/2009/07/02/lytebox-and-internet-explorer-8/ […]

  60. […] jest sporo porad, które pokazują co trzeba zrobić w plikach CSS. Rozwiązanie jest tu, na Terry’s Blog – jedyne […]

  61. […] https://nederveld.wordpress.com/2009/07/02/lytebox-and-internet-explorer-8/ http://lytebox.com/forums/viewtopic.php?f=2&t=28 Twitter Facebook Del.icio.us Reddit November 13, 2011 | Posted in: Uncategorized | No Comments » […]


Categories

%d bloggers like this: