0
var url = window.location.href;

result:

https://test.com/index.html?Event=90000002

how do I use Javascript to get 90000002 and put it in a variable?

Preamas
  • 1
  • 7

2 Answers2

0

You can use the .split() method

var data=url.split("=")[1]

Should return what you got after '='

Slye
  • 198
  • 2
  • 13
0

Though this is not optimized way but you can still do like this

Use location object and it's search property.

location.search will return ?Event=90000002. Then use substring to get the value

var a = location.search;
console.log(a.substring(7,a.length))
brk
  • 48,835
  • 10
  • 56
  • 78