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で個人的によく使う操作

Posted at

URLを操作

URL各要素取得

let url = new URL(location);

let href = location.href;
let host = location.hostname;
let port = location.port;
let path = location.pathname;
let query = location.search;
let protocol = location.protocol;

ブラウザー履歴エントリに state, title, url をセット

画面に更新をかけたくはない。
けどURLを更新したいというときに使ってます。

const url = new URL(window.location);
url.searchParams.set('foo', 'bar');
window.history.pushState({}, '', url); 

参照

0
0
0

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?