<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script type="text/javascript"> // document.write(JSON.stringify(returnCitySN)); var cname = JSON.stringify(returnCitySN.cname); var province = ''; if(cname.indexOf('省')!=-1){ var province = cname.substring(1,cname.indexOf('省')+1); }else if(cname.indexOf('区')!=-1){ province = cname.substring(1,cname.indexOf('区')+1); } var city = cname.substring(cname.indexOf('省')+1,cname.length-1); document.write('省:'+province+','+'市:'+city); </script>
原文链接:https://blog.csdn.net/cuilei210/java/article/details/78789880