Skip to main content

friendly-captcha-sdk > WidgetHandle

WidgetHandle class

This provides an API stub that provides the end-user JS API for a widget.

This class is only instantiated by the SDK - do not create a handle yourself.

Signature:

export declare class WidgetHandle 

Constructors

ConstructorModifiersDescription
(constructor)(opts)Constructs a new instance of the WidgetHandle class

Properties

PropertyModifiersTypeDescription
idreadonlystringA random ID that uniquely identifies this widget in this session.
isDestroyedbooleanWhen this is true the widget has been destroyed and can no longer be used.
sitekey?readonlystring(Optional) The sitekey for this widget. It can not be changed after creation of the widget.
startModeStartMode

Methods

MethodModifiersDescription
addEventListener(type, listener, options)Shorthand for this.getElement().addEventListener (that is strictly typed in Typescript)
destroy()

Destroy the widget.

This removes the element that the widget was mounted to as well as the hidden frc-captcha-response form field.

getElement()The HTML element that contains the widget.
getResponse()The current response of the widget. This is the value that should be sent to the server and is embedded in HTML forms.
getState()The current state of the widget.
removeEventListener(type, listener, options)Shorthand for this.getElement().removeEventListener (that is strictly typed in Typescript)
reset(opts)

Reset the widget, removing any progress.

Optional argument: an object with the name of the trigger that caused the reset. You would usually keep this empty. This is the trigger field in the frc:widget.reset event, which defaults to root.

start()Start the challenge. TODO: check what the current state is, in some states this probably shouldn't do anything.