javascript 获取查询字符串 [英] javascript get querystring

查看:50
本文介绍了javascript 获取查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
从javascript中的当前网址获取查询字符串?

我要获取网址中问号后的所有内容.我见过一种不需要函数但在我的生活中找不到它的方法.

I was to get everything after the question mark in the url. Ive seen a way to do it that does not require a function but cannot find it for the life of me.

网址

fsdhfbsdfj/index.html?hello

得到

hello

推荐答案

使用

var query = window.location.search;

如果你想去掉开头的?",使用

If you want to get rid of the starting "?", use

var query = window.location.search.slice(1);

此处描述了位置对象的属性.

这篇关于javascript 获取查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆