0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

javaScriptでURLのget情報を簡単に取得したい

Last updated at Posted at 2020-08-12

##はじめに

・更新日:2020/08/12
忘れないように、また忘れたとき用のメモです。
ちょっとずつ追加していきます

修正前:自分のためのjsメモ
修正後:javaScriptでURLのget情報を簡単に取得したい
コメントで指摘があったので修正しました。

・更新日:2020/08/15
※IEブラウザのみsearchParamsが使えないらしい
#javaScriptでURLのget情報を簡単に取得したい

script.js
//http://localhost/index.php?text=hogehoge&page=18
let params = (new URL(document.location)).searchParams;
let text = params.get('text');
let page = parseInt(params.get('page'));
console.log(text);
//hogehoge
console.log(page);
//18

参考→MDN

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?