首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    js得到当前页面的url信息

    所有的代码都是可用,而且附了图片的,不过是直接用我自己的文章地址,所以有些显示的有点奇怪。 大家可以找个网址试试代码是否可行。 1,设置或获取对象指定的文件名或路径。...2,设置或获取整个 URL 为字符串。 console.log(window.location.href); ? 3,设置或获取与 URL 关联的端口号码。...4,设置或获取 URL 的协议部分。 console.log(window.location.protocol) ? 5,设置或获取 href 属性中在井号“#”后面的分段。...7,设置或获取 href 属性中跟在问号后面的部分。 console.log(window.location.search) ?...8,获取变量的值(截取等号后面的部分) var url = window.location.search; console.log(JSON.stringify(url)); console.log

    7.1K41
    领券