Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascript µÄlastIndexOf

½üÈÕÊÕ¼¯ÉÏÍòÐдúÂ룬ÕûÀíһЩ³öÀ´¡£
//V8ÒýÇæµÄʵÏÖ
function ToInteger( n ) {
n = Number( n );
var sign = ( n < 0 ) ? -1 : 1;
if ( n != n ) {
return 0;
}
if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) {
return n;
}
return ( sign * Math.floor(Math.abs(n)) );
};
function lastIndexOf= (array,element, index) {
var length = array.length;
if (index == null) {
index = length - 1;
} else {
index = ToInteger(index);
// If index is negative, index from end of the array.
if (index < 0) index = length + index;
// If index is still negative, do not search the array.
if (index < 0) index = -1;
else if (index >= length) index = length - 1;
}
// Lookup through the array.
for (var i = index; i >= 0; i--) {
var current = array[i];
if ((current !== undefined) || i in this) {
if (current === element) return i;
}
}
return -1;
}
Ò»¸öÖØ´óµÄÎóÇøÊÇÒÔΪԭÉúAPI¶¼ÓÃCÓïÑÔʵÏÖ£¬Æäʵ²»È»£¬±ÈÈç»ðºüÓëchromeµÈÒÔËÙ¶ÈÖø³ÆµÄä¯ÀÀÆ÷£¬»ù±¾µÄ²¿·ÖÓÃCÓïÑÔʵÏÖºó£¬ÆäËûÇë¸ßÊָ㶨¡£±Ï¾¹ÓÃÆäËûÓïÑÔÀ´Ä£ÄâjavascriptºÜÈÝÒ×·¸´í£¬±ÈÈçIE6¡£ÍüÁË£¬ÄǶ«Î÷ÊǽÐJScript¡£
//Base2µÄʵÏÖ
function lastIndexOf(array, item, fromIndex) {
var length = array.length;
if (fromIndex == null) {
fromIndex = length - 1;
} else if (fromIndex < 0) {
fromIndex = Math.max(0, length + fromIndex);
}
for (var i = fromIndex; i >= 0; i--) {
if (array[i] === item) return i;
}
return -1;
}
//Prototype1.61µÄʵÏÖ
function lastIndexOf(array,item, i) {
i = isNaN(i) ? array.length : (i < 0 ? array.length + i : i) + 1;
var n = array.slice(0, i).reverse().indexOf(item);
return (n < 0) ? n : i - n - 1;


Ïà¹ØÎĵµ£º

Javascript½âÒÉ

Javascript½âÒÉ
1.        HTML¿ò¼ÜframesetµÄÓ¦ÓÃ
¿ò¼Ü±à³Ì¸ÅÊöÒ»¸öHTMLÒ³Ãæ¿ÉÒÔÓÐÒ»¸ö»ò¶à¸ö×Ó¿ò¼Ü£¬ÕâЩ×Ó¿ò¼ÜÒÔ<iframe>À´±ê¼Ç£¬ÓÃÀ´ÏÔʾһ¸ö¶ÀÁ¢µÄHTMLÒ³Ãæ¡£ÕâÀïËù½²µÄ¿ò¼Ü±à³Ì°üÀ¨¿ò¼ÜµÄ×ÔÎÒ¿ØÖÆÒÔ¼°¿ò¼ÜÖ®¼äµÄ»¥Ïà·ÃÎÊ£¬ÀýÈç´ÓÒ»¸ö¿ò¼ÜÖÐÒýÓÃÁíÒ»¸ö¿ò¼ÜÖеÄJavaScript± ......

ʹÓÃjavascript»ñÈ¡Îı¾¿ò,ÏÂÀ­¿ò,µ¥Ñ¡¿òµÄÖµ²¢ÇÒ¸³Öµ

1.Îı¾¿ò
1.1 <input type="text" name="test" id="test">
ͨ¹ývar t=document.getElementById("test").value°ÑÖµ¸³¸ø±äÁ¿t,
1.2  µ±È»Ò²¿ÉÒÔ·´¹ýÀ´°ÑÒÑÖªµÄ±äÁ¿Öµ¸³¸øÎı¾¿ò£¬ÀýÈ磺
var m = "5";
document.getElementById("test").value= m;
2.ÏÂÀ­Áбí¿ò
2.1 <select name="sel" id="sel" onchange ......

javascriptÃæÏò¶ÔÏó±à³Ì

·â×°£ºÍ¨¹ý±Õ°ü²ÅËãµÄÉÏÊÇÕæÕýÒâÒåÉϵķâ×°
<script type="text/javascript">
  function myInfo(){
    var name ="ÀÏÓã",age =27;
    var myInfo = "my name is" + name + "i am" + age  ......

JavaScriptÔËËã·ûÏê½â

       1¡¢javascript¾ßÓÐÏÂÁÐÖÖÀàµÄÔËËã·û£ºËãÊõÔËËã·û;µÈͬÔËËã·ûÓëȫͬÔËËã·û;±È½ÏÔËËã·û;
¡¡¡¡2¡¢Ä¿µÄ·ÖÀࣺ×Ö·û´®ÔËËã·û;Âß¼­ÔËËã·û;ÖðλÔËËã·û;¸³ÖµÔËËã·û;
¡¡¡¡3¡¢ÌØÊâÔËËã·û£ºÌõ¼þÔËËã·û;typeofÔËËã·û;´´½¨¶ÔÏóÔËËã·ûnew;deleteÔËËã·û;voidÔËËã·ûºÅ;¶ººÅÔËËã·û;
¡¡¡¡ËãÊõÔËËã·û£º ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ