1

OAuthを暗黙的に使用するAPIを使用しています。URLhttp://exmaple.com/#token=084758yhroufgbk48yにリダイレクトされます。

JavaScriptを介してこれを取得するにはどうすればよいですか?ありがとう

4

1 に答える 1

2

URLのハッシュ部分は次を使用して取得できますwindow.location.hash

URLからトークンを取得するには、次のコードを使用します。

<script type="text/javascript">
    hash = window.location.hash.substr(1); //url of the current page
    arHash = hash.split('='); //this creates an array with key ([0] element) and value ([1] element)
    hash_value =  arHash[1]; //recieve value
</script>
于 2012-04-14T13:24:34.203 に答える