gpt4 book ai didi

javascript - 如何从 URL 中只获取数字?

转载 作者:行者123 更新时间:2023-11-28 02:06:27 24 4
gpt4 key购买 nike

我在空白页上有这个 JavaScript:

Please show this number to your supplier:
<script>
document.write(document.URL);
</script>

所以它显示

"Please show this number to your supplier: http://www.exaple.com/invoices/123456789"

如何从网址中仅提取数字才能得到这个?

"Please show this number to your supplier: 123456789"

最佳答案

if (location.search != "")
{
var x = location.search.substr(1).replace(/%2520/g,' ').split(";")
for (var i=0; i<x.length; i++)
{
var y = x[i].split("=");
document.write(y[0])
}
}

关于javascript - 如何从 URL 中只获取数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17720708/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com