-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,256
  • 10
  • 65
  • 87

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
  • 21,981
  • 30
  • 95
  • 142
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,685
  • 5
  • 27
  • 64