HTMLGeolocationElement: HTMLGeolocationElement() コンストラクター
HTMLGeolocationElement() コンストラクターは、新しい HTMLGeolocationElement オブジェクトインスタンスを生成します。
構文
js
new HTMLGeolocationElement()
引数
なし。
返値
ブラウザーから内部的に使用された場合は、新しい HTMLGeolocationElement のオブジェクトインスタンス。
開発者は、HTMLGeolocationElement() コンストラクターを直接使用して新しい HTMLGeolocationElement インスタンスを作成することはできません。そうしようとすると、「不正なコンストラクター」エラーが発生します。
例
プログラムから新しい HTMLGeolocationElement インスタンスを作成
新しい HTMLGeolocationElement インスタンスをプログラムで作成するには、コンストラクタを直接使用しようとする代わりに、Document.createElement() を使用して新しい <geolocation> 要素インスタンスを作成します。
js
const geo = document.createElement("geolocation");
その後、DOM に追加することで使用することができます。
js
document.body.append(geo);