Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sorrycc
Created February 27, 2011 08:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorrycc/846006 to your computer and use it in GitHub Desktop.
Save sorrycc/846006 to your computer and use it in GitHub Desktop.
CSS Overflow Test Script
/**
* CSS Overflow Test Script
* @author sorrycc@gmail.com, @chenchengpro
* @doc http://www.chencheng.org/
*/
(function() {
// Text
var list = [], doc = document;
(function(parent) {
var func = arguments.callee,
nodes = parent.childNodes,
i = 0,
len = nodes.length;
for (; i<len; i++) {
var node = nodes[i];
if (node.nodeType === 1) {
func(node);
} else if (node.nodeType === 3) {
list.push(node);
}
}
})(doc.body);
for (var i=0; i<list.length; i++) {
var node = list[i],
value = node.nodeValue.replace(/^\s+|\s+$/g, ''),
tmpNode = doc.createTextNode(value);
if (value !== '' && value.length !== 1) {
node.parentNode.insertBefore(tmpNode, node);
}
}
// Image
var images = document.images, n = 0, len = images.length;
for (; n<len; n++) {
images[n].src = 'http://www.yoobao.com/shoppic/2010410425118938.jpg';
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment