JavascriptʵÓú¯Êý
function addLoadEvent(fun) {
var oldonload = window.onload;
if(typeof(window.onload) != 'function') {
window.onload = fun;
} else {
window.onload = function() {
oldonload();
fun();
}
}
}
//function insertAfter(newElement, targentElement)
function insertAfter(insertedNode, adjacentNode) {
var parent = adjacentNode.parentNode;
if(parent.lastChild == adjacentNode) {
parent.appendChild(insertedNode);
} else {
parent.insertBefore(insertedNode, adjacentNode.nextSibling);
}
}
Ïà¹ØÎĵµ£º
//»ñÈ¡µ±Ç°Îļþȫ·¾¶
<script language="javascript">
alert(window.location.href);
alert(window.location);
alert(location.href);
alert(parent.location.href);
alert(top.location.href);
alert(document.location.href);
alert(document.URL);
</scri ......
Ê×ÏÈÊÇÎÒÃÇÊìϤµÄextendº¯Êý
/**
* À©Õ¹º¯Êý
* @param target À©Õ¹¶ÔÏó
* @param params À©Õ¹²ÎÊý
*/
function extend(target, params) {
if (!target) {
target = {};
}
for (var prop in params) {
target[prop] = params[prop];
}
r ......
var greeting_w = {
c:['ÄãºÃ!', '»¶Ó»ØÀ´', '»¶Ó»Øµ½×éÖ¯', '×£ÄãºÃÐÄÇ飡', 'Hi~', 'Hello!', '*^o^*', ':D', 'ûʶàºÈË®', 'CR=ChinaRen', 'ÓÖ¼ûÃæÁË!', '¶àÔ˶¯ÉÙÉú²¡', '»¶ÓÀ´µØÇò~', '»¶ÓÀ´»ðÐÇ~', 'ÄãÌ«ÓвÅÁË!', 'hoho', 'ûʳԸöË®¹û', 'À´ºß¸ö¸è¶ù', '²ðÄÉÈÊ»¶ÓÄã!', 'ÏëtaÁËÂð?', 'ɶʱͬѧ»á?', '±£»¤º ......
ÒýÑÔ
JavaScript²»Êǰ´ÃæÏò¶ÔÏóµÄ˼ÏëÉè¼ÆµÄ³ÌÐòÓïÑÔ£¬ËùÒÔËü²»¾ß±¸ÏñÏÖÓеÄÃæÏò¶ÔÏóµÄÓïÑÔÄÇÑùµÄ¹¦ÄÜ£¬µ«ÊÇÃæÏò¶ÔÏóµÄ˼ÏëÊÇÈç´ËµÄÉîÈëÈËÐÄ£¬ÒÔÖÁÓÚJavaScriptÒ²Ï÷¼âÁËÄÔ´ü“ÃæÏò¶ÔÏó”¡£¹ûÕæ£¬Í¨¹ýÒ»Ð©ÌØÊâµÄ´¦Àí£¬JavaScriptÒ²¾ßÓÐÁË»ù±¾µÄÃæÏò¶ÔÏóµÄ¹¦ÄÜ¡£
......
1. Ó¦Óà Array.prototype.joinʵÏÖ×Ö·ûºÏ²¢
·½·¨1.
String.prototype.times = function(n) {
return Array.prototype.join.call({length:n+1}, this);
};
"js".times(5) // => "jsjsjsjsjs"
·½·¨2.
var ArrayTest=new Array("HE","LL","O");
var hello = Array.prot ......