MessagePort: close() method - Web APIs | MDN (original) (raw)
Baseline
Widely available
Note: This feature is available in Web Workers.
The close()
method of the MessagePortinterface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
Syntax
Parameters
None.
Return value
Examples
In the following code block, you can see a handleMessage
handler function, run when a message is sent back to this document usingEventTarget.addEventListener.
channel.port1.addEventListener("message", handleMessage, false);
function handleMessage(e) {
para.innerHTML = e.data;
textInput.value = "";
}
channel.port1.start();
You could stop messages being sent at any time using
Specifications
Specification |
---|
HTML # dom-messageport-close-dev |