Skip to content

Instantly share code, notes, and snippets.

View easy_error
/* can you spot what is happening here */
/* the alert("X") should never execute */
<script>
onload = function() {
var fn = function() {
alert("X");
}
(function() { })();
View quirks_detect.js
<html>
<head>
<title>Quirk Mode Test for Safari 2.0.x and other old browsers</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript">
// adapted from http://code.google.com/p/doctype/wiki/ArticleCompatMode
document.compatMode || (document.compatMode =
(function() {
var el; (el = document.createElement('div')).style.width = 1;
return el.style.width == '1px' ? 'BackCompat' : 'CSS1Compat';
View gist:179535
// first alert(1), then alert(2)
var foo = 1;
alert(1);
var bar = (function(){ alert(2); })();
// first alert(2), then alert(1)
var foo=1,bar=(function(){alert(2);})();alert(1);
View nodelist-to-array-concat.html
<!doctype html>
<html lang="en" dir="ltr">
<head>
<title>NodeList/HTMLCollection conversion/concatenation to array (testing)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
// get elapsed time
function timeElapsed(t) { return ((new Date()).getTime() - t); }
onload = function() {
View event-execution-order
<!DOCTYPE html>
<html>
<head>
<title>DOM Event test: order of execution</title>
<script type="text/javascript">
// W3C DOM Event test
(function() {
if (document.addEventListener) {
View SM_File_caps
js> File
function File() {
[native code]
}
js> Object.prototype.toString.call(File)
[object Function]
js>
js> stats("File")
0 0x10084a200 "separator" ENUMERATE READONLY slot 11 flags 4 shortid 0
0 0x10084a1c8 "error" ENUMERATE slot 10 flags 0 shortid 0
View gist:259584
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Focus Test</title>
<style type="text/css">
:focus { background-color: red; }
</style>
<script type="text/javascript">
window.onload = function() { document.body.setAttribute("tabindex", "1"); };
View selector_engine.js
Prototype._original_property = window.NW;
//= require "repository/src/nwmatcher"
Prototype.Selector = (function(engine) {
function select(selector, scope) {
return engine.select(selector, scope || document, Element.extend);
}
return {
engine: engine,
View simple_load.js
var loadScript = (function(global) {
return function(url) {
var script,
// document reference
doc = global.document,
// root element reference
View TouchEvent.html
<html>
<head>
<title>TouchEvent detection for iPhone/iPod/iPad</title>
<script type="text/javascript">
var isTouch = (function() {
var event, feature = false,
support = function() { feature = true; },
element = document.createElement('div');