Created
February 27, 2011 08:10
-
-
Save sorrycc/846006 to your computer and use it in GitHub Desktop.
CSS Overflow Test Script
This file contains hidden or 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
/** | |
* CSS Overflow Test Script | |
* @author [email protected], @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