Do common JavaScript implementations use string interning?

Yes. In general any literal string, identifier, or other constant string in JS source is interned. However implementation details (exactly what is interned for instance) varies, as well as when the interning occurs. Note that a string value is not the same as a String Object though, String Objects are not interned because that would … Read more

Detect rotation of Android phone in the browser with JavaScript

The actual behavior across different devices is inconsistent. The resize and orientationChange events can fire in a different sequence with varying frequency. Also, some values (e.g. screen.width and window.orientation) don’t always change when you expect. Avoid screen.width — it doesn’t change when rotating in iOS. The reliable approach is to listen to both resize and … Read more

How to style HTML5 range input to have different color before and after slider?

Pure CSS solution: Chrome: Hide the overflow from input[range], and fill all the space left to thumb with shadow color. IE: no need to reinvent the wheel: ::-ms-fill-lower Firefox no need to reinvent the wheel: ::-moz-range-progress /*Chrome*/ @media screen and (-webkit-min-device-pixel-ratio:0) { input[type=”range”] { overflow: hidden; width: 80px; -webkit-appearance: none; background-color: #9a905d; } input[type=”range”]::-webkit-slider-runnable-track { … Read more

Firing a Keyboard Event in Safari, using JavaScript

I am working on DOM Keyboard Event Level 3 polyfill . In latest browsers or with this polyfill you can do something like this: element.addEventListener(“keydown”, function(e){ console.log(e.key, e.char, e.keyCode) }) var e = new KeyboardEvent(“keydown”, {bubbles : true, cancelable : true, key : “Q”, char : “Q”, shiftKey : true}); element.dispatchEvent(e); //If you need legacy … Read more

How to remove the border highlight on an input text element

In your case, try: input.middle:focus { outline-width: 0; } Or in general, to affect all basic form elements: input:focus, select:focus, textarea:focus, button:focus { outline: none; } In the comments, Noah Whitmore suggested taking this even further to support elements that have the contenteditable attribute set to true (effectively making them a type of input element). … Read more