Saving a Uint8Array to a binary file

These are utilities that I use to download files cross-browser. The nifty thing about this is that you can actually set the download property of a link to the name you want your filename to be. FYI the mimeType for binary is application/octet-stream var downloadBlob, downloadURL; downloadBlob = function(data, fileName, mimeType) { var blob, url; … Read more

Background image stretch y-axis only, keep repeat-x

I had this problem too. It’s easy in most browsers, but IE8 and below it’s tricky. Solution for modern (anything not IE8 and below) browsers: #scroller_shadow { background: url(../img/ui/shadow.png) center repeat-x; background-size: auto 100%; } There are jQuery plugins that can mimic background-size for IE8 and below, specifically backgroundSize.js but it doesn’t work if you … Read more

Infinity vs Number.POSITIVE_INFINITY

TL;DR Infinity used to be overwritable; Number.POSITIVE_INFINITY and Number.NEGATIVE_INFINITY have always been read only. Infinity is a property of the global object (window is the global object for Javascript run in the browser), whereas Number.POSITIVE_INFINITY is a property of the Number constructor. Prior to the 5th Edition of ECMAScript, value properties of the global object … Read more

Manifest v3 background scripts/service worker on Firefox

Just faced the same problem: Chrome is not happy with background.scripts and insists on using background.service_worker Firefox doesn’t support background.service_worker and wants background.scripts Manifest v3 is developed by Google, so looks like Firefox team haven’t fully implemented it yet. Firefox 109 is the first version to “support” manifest v3 (released on January 17). I was … Read more

Back button of Google Chrome after clicking a hyperlink whose target is on the same PDF document

AFAIK there is no way to do it with the standard Chrome PDF Viewer. Take a look at their support page https://support.google.com/chrome/answer/1060734. You could try requesting this feature but keep in mind that the PDF viewer is part of Chrome, not Chromium.

What is the difference between testing on Safari vs Webkit?

Stock browsers like Google Chrome, Apple Safari embed rendering engines (Chromium, WebKit) and add stuff on top of them. In particular, they add proprietary media codecs, inject browser extensions, etc. They also add surrounding interfaces such as bookmarks sync. But they reuse the underlying web platform implementation. Chromium Chromium is the open source web platform … Read more

Get the offset position of the caret in a textarea in pixels [duplicate]

You can create a separate (invisible) element and fill it with textarea content from start to the cursor position. Textarea and the “clone” should have matching CSS (font properties, padding/margin/border and width). Then stack these elements on top of each other. Let me start with a working example, then walk through the code: http://jsfiddle.net/g7rBk/ Updated … Read more