What’s the most concise cross-browser way to access an element’s window and document?

There’s an easier way that’s been around longer… use window.frames to get a reference to the frame’s window object. By name or id: var iframe_doc = window.frames.my_iframe.document; or if you prefer: var iframe_doc = window.frames[‘my_iframe’].document; or by index: var iframe_doc = window.frames[0].document; Good reference for window.frames here: http://developer.mozilla.org/en/DOM/window.frames An excerpt: each item in the window.frames … Read more

How to change behavior of contenteditable blocks after on enter pressed in various browsers

As Douglas said earlier, browsers try to clone previous tag when customer starts a new paragraph on an editable page. The discrepancy occurs when browser has nothing to depart from – e.g. when initially the page body is empty. In this case different browsers behave differently: IE starts to wrap every string into <p> tag, … Read more

Retrieving HTML attribute values “the DOM 0 way”

jQuery’s attr() method is misleadingly named, badly documented and hides a very important distinction: the difference between attributes and properties, something which appears to be poorly understood by many web developers, particularly those whose introduction to JavaScript has come from jQuery. If you read no further, just take this away: you will almost never need … Read more

Using image.complete to find if image is cached on chrome?

I’ve rewritten your code in plain JavaScript, to make it more independent on jQuery. The core functionality hasn’t changed. Fiddle: http://jsfiddle.net/EmjQG/2/ function cached(url){ var test = document.createElement(“img”); test.src = url; return test.complete || test.width+test.height > 0; } var base_url = “http://www.google.com/images/srpr/nav_logo80.png” alert(“Expected: true or false\n” + cached(base_url) + “\n\nExpected: false (cache-busting enabled)\n” + cached(base_url + … Read more