lokesh/lightbox2

Vertical resize doesn't work with HTML 4.01

Closed this issue · 8 comments

Hello,
first of all let me say thanks for this script, I love it :)

I just realized that there's a problem with vertical resize when the page is HTML 4.01.
This happens in every modern browser, but NOT in Internet Explorer 11, where it works the way it should.

Here's you two examples with the same exact sample page in the latest Firefox:

  • With DOCTYPE html at the beginning, it works fine:
    https://ibb.co/BwbsgFk

  • With DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" it doesn't resize vertically (but it works horizontally):
    https://ibb.co/NZrG7cj

Is there a way to fix this? I need to use lightbox2 with some "old" 4.01 web pages.
Any help would be much appreciated :)

Perhaps, could it have to do with Quirks mode?

Here's you the two examples, same files, same css and same lightbox2 script (latest version):

  1. With the HTML5 tag: https://lightbox.tiiny.site/
  2. With the HTML4 tag: https://lightbox2.tiiny.site/

Nobody? Maybe I'm the only one having this problem?

It's not just you. Luckily for me, using DOCTYPE html was a good enough workaround, so thanks for that tip!

It's not just you. Luckily for me, using DOCTYPE html was a good enough workaround, so thanks for that tip!

No problem, glad I helped someone indirectly :)

Unfortunately I can’t fix it this way...replacing the doctype would screw the layout of my website (since it’s done with tables and deprecated tags)...

The issue seems to be jQuery reporting the document height as the window height.

I think I found a solution for you. In lightbox-plus-jquery.js, find the line that reads:

windowHeight = $(window).height();

change it to:

windowHeight = window.innerHeight;

That seems to work on my page, at least.

I don't know if windowWidth is affected in the same way, but if it is, change that line to windowWidth = window.innerWidth;

change it to:

windowHeight = window.innerHeight;

Well...it worked! Thank you so much @CommodoreSixtyFour ...and cool nickname by the way :)

Got started with a C64 back in the day. It's only fair to pay homage to it. :)

Glad you got your issue solved!