This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* readfile.js - Spidermonkey/V8 readfile wrapper | |
* | |
* Author: Diego Perini <diego.perini@gmail.com> | |
* | |
* Released under the Creative Commons license: | |
* http://creativecommons.org/licenses/by/3.0/ | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>IE capabilities detection (clientCaps)</title> | |
<script type="text/javascript"> | |
var r = document.documentElement, capabilities; | |
r.addBehavior("#default#clientCaps"); | |
capabilities = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: should probably convert result to plain array (since different engines return different things -- arrays, nodelists, objects, etc.) | |
var query = (function() { | |
var engine, engines = 'NW.Dom.select,base2.dom.querySelectorAll,Sizzle,$$,$,YAHOO.util.Selector.query,dojo.query,Ext.DomQuery.select'.split(','); | |
while ((engine = engines.shift())) { | |
if (Function('try{return ' + engine + '}catch(e){}')()) { | |
return Function('cssExpr, ctx', 'ctx || (ctx = document);return ' + engine + '(' + | |
(engine.indexOf('base2') > -1 ? 'ctx, cssExpr' : 'cssExpr, ctx') + ')'); | |
} | |
} | |
return 'querySelectorAll' in document ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is how I fixed IE6-8 crashing on | |
// dynamic insertion of at-rules inside | |
// stylesheets (for example @font-face) | |
// UPDATE: | |
// Fix by MS, move up the style insertion | |
// before the stylesheet rule manipulation | |
function setStyle(rules) { | |
var d = document, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loadScript = (function(global) { | |
return function(url) { | |
var script, | |
// document reference | |
doc = global.document, | |
// root element reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DOM Event test: order of execution</title> | |
<script type="text/javascript"> | |
// W3C DOM Event test | |
(function() { | |
if (document.addEventListener) { |