JavaScriptÖеÄindexOf·½·¨
1.¶ÔÓÚÊý×飬ÎÒÃÇ¿ÉÒÔ×Ô¼ºÐ´Ò»¸öindexOf()·½·¨:
[].indexOf || (Array.prototype.indexOf = function(v){
for(var i = this.length;i-- && this[i] !== v;);
return i; });
ʹÓ㺠var array = new Array();
array = ...;
if(array.indexOf("...")==-1){
...
}
2.µ±È»ÉÏÃæµÄ·½·¨ÓÐЩÂé·³£¬ÎÒÃÇÒ»°ã²»ÐèÒª×Ô¼ºÀ´¶¨ÒåÊý×éµÄindexOf()£¬¶øÊÇÖ±½ÓʹÓÃJavaScript×Ô´øµÄStringµÄindexOf()·½·¨¼´¿É¡£
ÓÚÊÇ£¬¶ÔÓÚÉÏÃæµÄÀý×Ó£¬¿ÉÒÔ¸Äд³É£º
ʹÓ㺠var array = new Array();
array = ...;
array = array.toString();
if(array.indexOf("...")==-1){
...
}
Ïà¹ØÎĵµ£º
var OnPasteCheckIntNum = function()
{
if(window.clipboardData)
{
if(isNaN(window.clipboardData.getData('text')))
{
......
JavaScriptÌṩÁËÒ»¸öRegExp¶ÔÏóÀ´Íê³ÉÓйØÕýÔò±í´ïʽµÄ²Ù×÷ºÍ¹¦ÄÜ£¬Ã¿Ò»ÌõÕýÔò±í´ïʽģʽ¶ÔÓ¦Ò»¸öRegExpʵÀý¡£ÓÐÁ½ÖÖ·½Ê½¿ÉÒÔ´´½¨RegExp¶ÔÏóµÄʵÀý¡£
ʹÓÃRegExpµÄÏÔʽ¹¹Ô캯Êý£¬Ó﷨Ϊ£ºnew RegExp("pattern"[,"flags"])¡£
ʹÓÃRegExpµÄÒþʽ¹¹Ô캯Êý£¬²ÉÓô¿Îı¾¸ñʽ£º/pattern/[flags]¡£
pattern²¿·ÖΪҪʹÓõÄÕýÔò ......
// s_id1: selectµÄid
var objSelect = document.getElementById(”s_id1”);
//»ñµÃË÷Òý
var indexSelect = objSelect .selectedIndex;
//»ñµÃselectÎı¾
var txtSelect = objSelect .options[index].text;
//»ñµÃselectÖµ
var valSelect = objSelect .options[index].value;
//¸Ä±äselect ......
±¾ÎÄ×÷ÕßΪDavid
Mandelin£¬©¤©¤Mozilla JavaScriptÍŶӹ¤×÷ÈËÔ±¡£
Firefox 3.5ÓµÓÐÒ»¸öȫеÄJavaScriptÒýÇæ£¬½Ð×öTraceMonkey£¬ÔÚ¸ÃÒýÇæÉÏÅÜJSÓ¦ÓÃÒª±ÈFirefox
3¿ìµ½3-4±¶£¬´Ó¶øÎªÏÖÓеÄÍøÂçÓ¦ÓüÓËÙ¡£ÕâÆªÎÄÕ´óÖµÄÃèÊöÒ»ÏÂÔÚTraceMonkeyÖаüÀ¨µÄÖØÒª²¿¼þ£¬ÒÔ¼°ËûÃÇÊÇÈçºÎ¼ÓËÙJavaScriptµÄ¡£Í¬Ñù£¬ÔÚÁ˽âÕâÐ ......
//·þÎñÆ÷µ¯³ö¶Ô»°¿ò
if (lcSID == "1" && (txtNsp.Text.Trim() != lcNewspaper || Convert.ToDateTime(txtNspdate.Text.Trim()) != Convert.ToDateTime(lcNspdate)))
{
string lcJs = "v ......