What does do?

November 2021 Update As this answer is now 10+ years old my recommendation would be to leave this tag out altogether, unless you must support old legacy browsers. October 2015 Update This answer was posted several years ago and now the question really should be should you even consider using the X-UA-Compatible tag on your … Read more

WebBrowser Control in a new thread

You have to create an STA thread that pumps a message loop. That’s the only hospitable environment for an ActiveX component like WebBrowser. You won’t get the DocumentCompleted event otherwise. Some sample code: private void runBrowserThread(Uri url) { var th = new Thread(() => { var br = new WebBrowser(); br.DocumentCompleted += browser_DocumentCompleted; br.Navigate(url); Application.Run(); … Read more

How to encode the filename parameter of Content-Disposition header in HTTP?

I know this is an old post but it is still very relevant. I have found that modern browsers support rfc5987, which allows utf-8 encoding, percentage encoded (url-encoded). Then Naïve file.txt becomes: Content-Disposition: attachment; filename*=UTF-8”Na%C3%AFve%20file.txt Safari (5) does not support this. Instead you should use the Safari standard of writing the file name directly in … Read more

Embedding Base64 Images

Update: 2017-01-10 Data URIs are now supported by all major browsers. IE supports embedding images since version 8 as well. http://caniuse.com/#feat=datauri Data URIs are now supported by the following web browsers: Gecko-based, such as Firefox, SeaMonkey, XeroBank, Camino, Fennec and K-Meleon Konqueror, via KDE’s KIO slaves input/output system Opera (including devices such as the Nintendo … Read more

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

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

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