<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="智能社 - zhinengshe.com" /> <meta name="copyright" content="智能社 - zhinengshe.com" /> <title>智能社 - www.zhinengshe.com</title> <style> </style> <script> window.onload = function(){ var oText = document.getElementById("txt1"); var oBtn = document.getElementById("btn1"); //http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15657123900 var url = "http://tcc.taobao.com/cc/json/mobile_tel_segment.htm" oBtn.onclick = function(){ var oS = document.createElement("script"); oS.src = url + "?tel=" + oText.value; document.body.appendChild(oS); if(document.addEventListener){ //高级 oS.onload = function(){ alert(__GetZoneResult_ ); }; } else { //ie8- oS.onreadystatechange = function(){ if(oS.readyState){ if(oS.readyState == "loaded" ||oS.readyState == "complete"){ alert(__GetZoneResult_ ); } } }; } }; }; </script> </head> <body> <input id="txt1" type="text" value="15657123920"/> <input id="btn1" type="button" value="查询"/> <ul id="ul1"> </ul> </body> </html>
//版权 北京智能社©, 保留所有权利 //options url data cbName timeout success error function jsonp(options){ options = options || {}; if(!options.url){ return; } options.data = options.data || {}; options.cbName = options.cbName || "cb"; options.timeout = options.timeout || 0; var fnName = ("jsonp"+Math.random()).replace(".",""); options.data[options.cbName] = fnName; //拼数据 var arr = []; for(var name in options.data){ arr.push(name + "=" + encodeURIComponent(options.data[name])); } var str = arr.join("&"); window[fnName] = function(json){ options.success && options.success(json); //清理 oHead.removeChild(oS); clearTimeout(timer); }; //1 创建script var oS = document.createElement("script"); oS.src = options.url + "?" + str; var oHead = document.getElementsByTagName("head")[0]; oHead.appendChild(oS); //超时 if(options.timeout){ var timer = setTimeout(function(){ options.error && options.error(); //清理 window[fnName] = function(){}; oHead.removeChild(oS); },options.timeout); } }