js获取ip和地区

这个接口是搜狐的目前是可用的, 就是不知道以后会不会失效

效果图:

js获取ip和地区

代码如下:

<!doctype html> <html> <head> <meta charset="utf-8"> <title>t1</title> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"> <style> /* css reset */ body,p,ol,ul,li,dl,dd,h1,h2,h3,h4,h5,h6,input,iframe,nav,header,footer { margin: 0; padding: 0; list-style: none; } body { font: 16px Microsoft YaHei, sans-serif; color: #2a2b2c; background: #fff; } a,img { text-decoration: none; color: #2a2b2c; border: 0; } *, *::before, *::after { outline: none; box-sizing: border-box; } .xxx-btn { display: block; width: 100px; height: 38px; font: 16px/38px Microsoft YaHei; color: #fff; background: #0cf; border: 0; cursor: pointer; text-align: center; border-radius: 2px; box-shadow: 0 1px 5px #bbb; opacity: .8; transition: .5s; } .xxx-btn:hover { opacity: 1; box-shadow: 0 1px 10px #aaa; } </style> </head> <body> <h1>点击获取ip</h1> <br> <button>click me</button> <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script> function aa() { alert(returnCitySN['cip'] + returnCitySN['cname']); }; </script> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwwjpg.html