Is there a way to detect if a browser window is not currently active?

Since originally writing this answer, a new specification has reached recommendation status thanks to the W3C. The Page Visibility API (on MDN) now allows us to more accurately detect when a page is hidden to the user. document.addEventListener(“visibilitychange”, onchange); Current browser support: Chrome 13+ Internet Explorer 10+ Firefox 10+ Opera 12.10+ [read notes] The following code … Read more

Hiding the scroll bar on an HTML page

WebKit supports scrollbar pseudo elements that can be hidden with standard CSS rules: #element::-webkit-scrollbar { display: none; } If you want all scrollbars hidden, use ::-webkit-scrollbar { display: none; } I’m not sure about restoring – this did work, but there might be a right way to do it: ::-webkit-scrollbar { display: block; } You … Read more

What is JavaScript’s highest integer value that a number can go to without losing precision?

JavaScript has two number types: Number and BigInt. The most frequently-used number type, Number, is a 64-bit floating point IEEE 754 number. The largest exact integral value of this type is Number.MAX_SAFE_INTEGER, which is: 253-1, or +/- 9,007,199,254,740,991, or nine quadrillion seven trillion one hundred ninety-nine billion two hundred fifty-four million seven hundred forty thousand … Read more

WebSockets vs. Server-Sent events/EventSource

Websockets and SSE (Server Sent Events) are both capable of pushing data to browsers, however they are not competing technologies. Websockets connections can both send data to the browser and receive data from the browser. A good example of an application that could use websockets is a chat application. SSE connections can only push data … Read more

How can I tell if a DOM element is visible in the current viewport?

Now most browsers support getBoundingClientRect method, which has become the best practice. Using an old answer is very slow, not accurate and has several bugs. The solution selected as correct is almost never precise. This solution was tested on Internet Explorer 7 (and later), iOS 5 (and later) Safari, Android 2.0 (Eclair) and later, BlackBerry, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)