Skip to main content
Version: 24.38.0

Page.setGeolocation() 方法

🌐 Page.setGeolocation() method

设置页面的地理位置。

🌐 Sets the page's geolocation.

语法

🌐 Signature

class Page {
abstract setGeolocation(options: GeolocationOptions): Promise<void>;
}

参数

🌐 Parameters

范围

🌐 Parameter

类型

🌐 Type

描述

🌐 Description

options

地理位置选项

返回:

Promise<void>

附注

🌐 Remarks

考虑使用 BrowserContext.overridePermissions() 来授予页面读取其地理位置的权限。

🌐 Consider using BrowserContext.overridePermissions() to grant permissions for the page to read its geolocation.

示例

🌐 Example

await page.setGeolocation({latitude: 59.95, longitude: 30.31667});