-1

I have a URL like

http://something.com?acess_token=ashv6786sdjfhjd

When I click on that link, how to get the access_token from that link using Javascript?

pedram
  • 6,577
  • 10
  • 57
  • 84

2 Answers2

1

Try :

var Yoururl= "http://something.com?acess_token=ashv6786sdjfhjd";
var acessToken=Yoururl.split('?')[1].split('=')[1];

Working Fiddle

For url parameter see old so question from given link. Get url parameter via jquery

Community
  • 1
  • 1
4b0
  • 20,627
  • 30
  • 92
  • 137
0

If you want the value of the access_token you mean this:

ashv6786sdjfhjd

Then here's a quick solution. Hope it helps!

var str = "http://something.com?acess_token=ashv6786sdjfhjd.when";
var accessToken = str.split("=")[1].split(".")[0];
console.log(accessToken);
HenryDev
  • 4,365
  • 5
  • 23
  • 57