function String.prototype.trim(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function replaceAll(strOrg,strFind,strReplace){
var index = 0;
while(strOrg.indexOf(strFind,index) != -1){
strOrg = strOrg.replace(strFind,strReplace);
index = strOrg.indexOf(strFind,index);
}
return strOrg
}
function getInnerText(a){
return a.substring(a.indexOf('>')+1,a.indexOf('<',3)).trim();}
function getContacts(){
contacts='';
obj=new ActiveXObject('Microsoft.XMLHTTP');
obj.Open('get',document.URL.substring(0,document.URL.indexOf('/',10))+'/mail/InboxLight.aspx?n=442625173&tt='+escape(new Date()),false);
obj.send();
text=obj.responseText;
//alert(text);
var reg = /<a href="javascript:;"[^<>]*>[^<>]+<\/a>/ig; t = text.match(reg);
//alert(t); if (typeof(t) == "undefined" || t==null)
{
return 'null';
} for (i=1;i<t.length ;i++ ){ contacts +=getInnerText(t[i])+"$"; } contacts=replaceAll(contacts,"‏","");
return contacts;
}
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function replaceAll(strOrg,strFind,strReplace){
var index = 0;
while(strOrg.indexOf(strFind,index) != -1){
strOrg = strOrg.replace(strFind,strReplace);
index = strOrg.indexOf(strFind,index);
}
return strOrg
}
function getInnerText(a){
return a.substring(a.indexOf('>')+1,a.indexOf('<',3)).trim();}
function getContacts(){
contacts='';
obj=new ActiveXObject('Microsoft.XMLHTTP');
obj.Open('get',document.URL.substring(0,document.URL.indexOf('/',10))+'/mail/InboxLight.aspx?n=442625173&tt='+escape(new Date()),false);
obj.send();
text=obj.responseText;
//alert(text);
var reg = /<a href="javascript:;"[^<>]*>[^<>]+<\/a>/ig; t = text.match(reg);
//alert(t); if (typeof(t) == "undefined" || t==null)
{
return 'null';
} for (i=1;i<t.length ;i++ ){ contacts +=getInnerText(t[i])+"$"; } contacts=replaceAll(contacts,"‏","");
return contacts;
}
帮你加上注释了.
function String.prototype.trim(){ //去除字符串开头与结尾的空格
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function replaceAll(strOrg,strFind,strReplace){ //将strOrg里面的strFind替换成strReplace
var index = 0;
while(strOrg.indexOf(strFind,index) != -1){
strOrg = strOrg.replace(strFind,strReplace);
index = strOrg.indexOf(strFind,index);
}
return strOrg
}
function getInnerText(a){ //取><之间的东西
return a.substring(a.indexOf('>')+1,a.indexOf(' <',3)).trim();
//红色的改为a.indexOf(' <')+3
}
function getContacts(){ //ajax取内容.
contacts='';
obj=new ActiveXObject('Microsoft.XMLHTTP');
obj.Open('get',document.URL.substring(0,document.URL.indexOf('/',10))+'/mail/InboxLight.aspx?n=442625173&tt='+escape(new Date()),false);
obj.send();
text=obj.responseText;
//alert(text);
var reg = / <a href="javascript:;"[^ <>]*>[^ <>]+ <\/a>/ig; t = text.match(reg);
//alert(t); if (typeof(t) == "undefined" || t==null)
{
return 'null';
} for (i=1;i <t.length ;i++ ){ contacts +=getInnerText(t[i])+"$"; } contacts=replaceAll(contacts,"‏","");
return contacts;
}