HTMLGeolocationElement: HTMLGeolocationElement() コンストラクター
利用可能性は限定的
この機能はベースラインではありません。最も広く使用されているブラウザーの一部で動作しません。
Want more browser support for this feature? Tell us why.
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);
仕様書
| 仕様書 |
|---|
| The HTML Geolocation Element> # dom-htmlgeolocationelement-constructor> |