Skip to main content
Branch: Development

WebView

Hierarchy

  • BaseObject
    • WebView

Index

Constructors

constructor

  • new WebView(url: string, isOverlay?: boolean): WebView
  • new WebView(url: string, propHash: number, targetTexture: string): WebView
  • Creates a fullscreen WebView.

    Example

    // Let's imagine such file structure:
    // resource/
    // ├─ client/
    // │ ├─ script.js
    // │ ├─ index.html

    index.html

    <div>Example</div>

    script.js

    // <http://resource> is the resource directory (resource root)
    const webview = new alt.WebView("http://resource/client/index.html")

Properties

publicfocused

focused: boolean

Is the webview focused.

publicreadonlyid

id: number

publicreadonlyisOverlay

isOverlay: boolean

Is the webview a overlay.

publicreadonlyisReady

isReady: boolean

Is the webview ready.

publicreadonlyisRemote

isRemote: boolean

Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true).

publicisVisible

isVisible: boolean

View visibility state

publicreadonlypos

pos: Vector2

Set and get the webview position.

publicreadonlyrefCount

refCount: number

Returns the ref count of the entity.

Remarks

It’s only available in debug-mode.

publicreadonlyremoteID

remoteID: number

The serverside id of this entity.

publicsize

size: Vector2

Set and get the webview size.

publicreadonlytype

type: BaseObjectType

Type of the object.

publicurl

url: string

View URL

publicreadonlyvalid

valid: boolean

Object usability.

Returns

False if object is no longer usable.

publicstaticreadonlyall

all: readonly WebView[]

publicstaticreadonlycount

count: number

publicstaticreadonlygpuAccelerationActive

gpuAccelerationActive: boolean

Methods

publicaddOutput

  • addOutput(output: AudioOutput): void

publicdeleteMeta

  • deleteMeta(key: string): void
  • deleteMeta<K>(key: K): void

publicdestroy

  • destroy(): void
  • Removes the object from the world.

publicemit

  • emit(eventName: string, ...args: any[]): void
  • Emits specified event across particular WebView.

publicfocus

  • focus(): void
  • Focuses the webview so it can be interacted with.

publicgetEventListeners

  • getEventListeners(eventName: null | string): readonly (...args: any[]) => void[]
  • Gets all the listeners for the specified webview event.

publicgetMeta

  • getMeta<K>(key: Exclude<K, never>): unknown
  • getMeta<K>(key: K): undefined | ICustomWebViewMeta[K]
  • getMeta<V>(key: string): undefined | V
  • Type parameters

    • K: string

publicgetMetaDataKeys

  • getMetaDataKeys(): readonly string[]

publicgetOutputs

  • getOutputs(): readonly (number | AudioOutput)[]

publicgetSyncedMeta

  • getSyncedMeta<K>(key: Exclude<K, never>): unknown
  • getSyncedMeta<K>(key: K): undefined | ICustomBaseObjectSyncedMeta[K]
  • getSyncedMeta<V>(key: string): undefined | V
  • Gets a value using the specified key.


    Type parameters

    • K: string

publicgetSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

publichasMeta

  • hasMeta(key: string): boolean
  • hasMeta<K>(key: K): boolean

publichasSyncedMeta

  • hasSyncedMeta(key: string): boolean
  • hasSyncedMeta<K>(key: K): boolean
  • Determines whether contains the specified key.

publicoff

  • off(eventName: string, listener: (...args: any[]) => void): void
  • Unsubscribes from WebView event handler with specified listener.

    Remarks

    Listener should be of the same reference as when event was subscribed.

publicon

  • on(eventName: string, listener: (...args: any[]) => void): void
  • on(eventName: load, listener: () => void): void
  • Subscribes to WebView event handler with specified listener.

publiconce

  • once(eventName: string, listener: (...args: any[]) => void): void
  • Subscribes to WebView event with specified listener, which only triggers once.

publicreload

  • reload(ignoreCache?: boolean): void

publicremoveOutput

  • removeOutput(output: AudioOutput): void

publicsetExtraHeader

  • setExtraHeader(header: string, value: string): void
  • Sets the specified header to the specified value.

publicsetMeta

  • setMeta<K>(key: K, value: InterfaceValueByKey<ICustomWebViewMeta, K, unknown, void>): void
  • setMeta<K>(key: K, value: ICustomWebViewMeta[K]): void
  • setMeta<V, K>(key: K, value: InterfaceValueByKey<ICustomWebViewMeta, K, V, void>): void
  • Type parameters

    • K: string

publicsetZoomLevel

  • setZoomLevel(value: number): void
  • Sets the zoom level for webview.

publicunfocus

  • unfocus(): void
  • Unfocuses the webview so it ignores user input.

publicstaticgetByID

  • getByID(id: number): null | WebView
  • Retrieves the webview from the pool.

publicstaticgetByRemoteID

  • getByRemoteID(type: BaseObjectType, id: number): null | BaseObject