I’m working with some code that’s been worked over many, many times over the years. It could a thorough scrubbing, but that’s not in the scope of my request.
I just upgraded the jQuery UI to version 1.9.2 and jQuery to 1.8.3 and added a simple dialog.
It was expected that the dialog would center itself to the browser window. However it appeared to be centering itself to the html element and scrolling the page to make it centered if the content was longer than the window height.
Here’s the code:
<html> <head> <title>My Title</title> </head> <body> <div id="userNoticeDialog" style="display: none;" title="Notice"> test content </div> <script type="text/javascript"> $("#userNoticeDialog").dialog(); </script> </body> </html>
After a process of elimination and seeing that there was no doctype declared, I tried adding a doctype. That resolved the issue.
<!DOCTYPE html> <html> <head> <title>My Title</title> </head> <body> <div id="userNoticeDialog" style="display: none;" title="Notice"> test content </div> <script type="text/javascript"> $("#userNoticeDialog").dialog(); </script> </body> </html>
I believe the reason was the lack of a DOCTYPE caused the (Chrome) browser to go into quirks mode, while the inclusion of the DOCTYPE caused the (Chrome) browser to go into standards mode. However, I’m not sure how to detect which mode the Chrome browser is currently in. Does anyone know?