Class HTMLDialogElement
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The HTMLDialogElement interface provides methods to manipulate {{HTMLElement("dialog")}} elements. It inherits properties and methods from the HTMLElement interface.
[Value("HTMLDialogElement")]
public class HTMLDialogElement : HTMLElement
- Inheritance
-
HTMLDialogElement
- Inherited Members
Remarks
-The HTML element implementing this interface: dialog.
Constructors
HTMLDialogElement()
public HTMLDialogElement()
Properties
ClosedBy
The closedBy property of the
HTMLDialogElement interface indicates the types of user actions that can be used to close the associated {{htmlelement("dialog")}} element. It sets or returns the dialog's closedby attribute value.
[Value("closedBy")]
public string ClosedBy { get; set; }
Property Value
- string
A string; possible values are:
Remarks
Open
The open property of the
HTMLDialogElement interface is a boolean value reflecting theopen HTML attribute, indicating whether the dialog is
available for interaction.
[Value("open")]
public bool Open { get; set; }
Property Value
- bool
A boolean value representing the state of the
openHTML attribute. A value oftruemeans that the dialog is showing, whilefalsemeans it's not showing.WARNING
While theopenproperty is technically not read-only and can be set directly, doing so is strongly discouraged by the HTML specification, as it can break normal dialog interactions in unexpected ways. For example, thecloseevent won't fire when programmatically settingopentofalse, and subsequent calls to theclose()andrequestClose()methods will have no effect. Instead, it's better to use methods such asshow(),showModal(),close(), andrequestClose()to change the value of theopenattribute.
Remarks
-The HTML element implementing this interface: dialog.
ReturnValue
The returnValue property of the HTMLDialogElement interface is a string representing the return value for a {{htmlelement("dialog")}} element when it's closed.
You can set the value directly (dialog.returnValue = "result") or by providing the value as a string argument to Close(string) or RequestClose(string).
[Value("returnValue")]
public string ReturnValue { get; set; }
Property Value
- string
A string representing the
returnValueof the dialog.
Defaults to an empty string ("").
Remarks
-The HTML element implementing this interface: dialog.
Methods
Close(string)
The close() method of the HTMLDialogElement interface closes the {{htmlelement("dialog")}}.
An optional string may be passed as an argument, updating the returnValue of the dialog.
[Value("close")]
public GlobalObject.Undefined Close(string returnValue = null)
Parameters
returnValuestring
Returns
Remarks
-The HTML element implementing this interface: dialog.
RequestClose(string)
The requestClose() method of the HTMLDialogElement interface requests to close the {{htmlelement("dialog")}}.
An optional string may be passed as an argument, updating the returnValue of the dialog.
[Value("requestClose")]
public GlobalObject.Undefined RequestClose(string returnValue = null)
Parameters
returnValuestring
Returns
Remarks
This method differs from the Close(string) method in that it fires a HTMLDialogElement.Cancel event before firing the Close(string) event.
Authors can call PreventDefault() in the handler for the cancel event to prevent the dialog from closing.
This method exposes the same behavior as the dialog's internal close watcher.
-The HTML element implementing this interface: dialog.
Show()
The show() method of the HTMLDialogElement
interface displays the dialog modelessly, i.e., still allowing interaction with content
outside of the dialog.
[Value("show")]
public GlobalObject.Undefined Show()
Returns
Remarks
-The HTML element implementing this interface: dialog.
ShowModal()
The showModal() method of the
HTMLDialogElement interface displays the dialog as a modal, over the top
of any other dialogs that might be present. It displays in the top layer, along with a
{{cssxref('::backdrop')}} pseudo-element. Elements inside the same document as the dialog, except the dialog and its descendants, become inert (as if the inert attribute is specified). Only the containing document becomes blocked; if the dialog is rendered inside an iframe, the rest of the page remains interactive.
[Value("showModal")]
public GlobalObject.Undefined ShowModal()
Returns
Remarks
-The HTML element implementing this interface: dialog.