如何在JavaScript中使用URL
例如,我有一个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
如何获取某物的内容“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是您的朋友。