Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JavaScript中使用URL_Javascript - Fatal编程技术网

如何在JavaScript中使用URL

如何在JavaScript中使用URL,javascript,Javascript,例如,我有一个URL: 如何获取某物的内容“abc”和a的内容作为字符串 提前感谢,, Mateiaru使用函数助手: function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||nul

例如,我有一个URL:

如何获取某物的内容“abc”和a的内容作为字符串

提前感谢,, Mateiaru

使用函数助手:

function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
那么就这样称呼它:

var aValue = getURLParameter(a);
使用函数帮助器:

function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
那么就这样称呼它:

var aValue = getURLParameter(a);

document.URL或window.location您可以将当前URL作为字符串获取。您可以对其进行操作。您尝试了什么吗?可能重复的-Google是您的朋友。document.URL或window.location您可以将当前URL作为字符串获取。您可以对其进行操作。您尝试了什么吗?可能重复的-Google是您的朋友。