js获取当前页面的url网址信息
JS 获取 信息 页面 当前 url 网址
2023-09-14 08:57:36 时间
设置或获取整个 URL 为字符串:
window.location.href
获取内容:http://10.100.0.8:7000/SVP/
"window.location.href" "http://10.30.60.187:7000/PPIS/templates/WfrmMain_Test.html"
备注:设置页面跳转,可更改此值
设置或获取与 URL 关联的端口号码:
window.location.port:7000
设置或获取 URL 的协议部分
window.location.protocol
设置或获取 href 属性中跟在问号后面的部分
window.location.search
获取变量的值(截取等号后面的部分)
复制代码 代码如下:
var url = window.location.search;
// alert(url.length);
// alert(url.lastIndexOf('='));
var loc = url.substring(url.lastIndexOf('=')+1, url.length);
设置或获取 href 属性中在井号“#”后面的分段:
window.location.hash
设置或获取 location 或 URL 的 hostname 和 port 号码:
window.location.host
获取内容:10.100.0.8:7000
window.location.hostname
获取内容:10.100.0.8
获取当前用户访问的ip地址以及城市地区
前提:需要联网
引用下面的js:
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
直接获取IP和城市名:
alert(returnCitySN['cip'] + returnCitySN['cname']);
其他
"document.domain" "10.30.60.187"
个人随笔,如有错误,敬请指正
相关文章
- JS框架_(JQuery.js)模拟刮奖
- js中实现多态
- JS - 获取页面滚动的高度
- JS魔法堂:函数重载 之 获取变量的数据类型
- js获取客户端time,cookie,url,ip,refer,user_agent信息:
- js获取select改变事件
- 原 JS监听回车事件
- Cocos2d-JS内置粒子系统
- js获取本机mac地址,IP地址,计算机名
- js和jquery获取父级元素、子级元素、兄弟元素的方法{转}
- js中获取时间new date()的用法
- JS获取当前网址信息
- [Ethereum] 浅谈加密商品市场 OpenSea 与 opensea-js
- when is SAP UI5 sap-ui-core.js loaded
- Atitit.dart语言的特性 编译时js语言大总结
- JS获取当前周、上一周、下一周日期demo效果(整理)
- js 移动端上拉刷新(基于ng1)
- 手写实现 js 中的bind,并实现 softBind
- js和jquery获取textarea输入的内容
- (效果五)js获取客户端ip地址及浏览器信息
- 深入学习js的classList
- js两个一维数组合并并去除相同项(整理)
- js中将byte数组转换成base64图片显示