<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKUserContentController/removeScriptMessageHandler(forName:contentWorld:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKUserContentController(im)removeScriptMessageHandlerForName:contentWorld:"
  },
  "title" : "removeScriptMessageHandler(forName:contentWorld:)"
}
-->

# removeScriptMessageHandler(forName:contentWorld:)

Uninstalls a custom message handler from the specified content world in your JavaScript code.

```
func removeScriptMessageHandler(forName name: String, contentWorld: WKContentWorld)
```

## Parameters

`name`

The name of the message handler to remove. If no message handler with this name exists in the user content controller, this method does nothing.

`contentWorld`

The content world from which to remove the message handler. For more information about content worlds, see [`WKContentWorld`](/documentation/WebKit/WKContentWorld).

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)