現在のURLを取得するJavaScriptプログラム

Javascript

例:現在のURLを取得する

// program to get the URL

const url1 = window.location.href;
const url2 = document.URL;
console.log(url1);
console.log(url2);

出力

https://www.google.com/
https://www.google.com/

上記のプログラムでは、 window.location.href プロパティと document.URL プロパティは、現在のページのURLを取得するために使用されます。

両方 window.location.href そしてその document.URL プロパティは、現在のページのURLを返します。



Hope this helps!

Source link

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です