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

# removeScriptMessageHandler(forName:)

Uninstalls the custom message handler with the specified name from your JavaScript code.

```
func removeScriptMessageHandler(forName name: String)
```

## 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.

## Discussion

Use this method to remove a message handler that you previously installed using the [`add(_:name:)`](/documentation/WebKit/WKUserContentController/add(_:name:)) method. This method removes the message handler from the page content world — that is, the content world available from the [`page`](/documentation/WebKit/WKContentWorld/page) property of [`WKContentWorld`](/documentation/WebKit/WKContentWorld). If you installed the message handler in a different content world, this method doesn’t remove it.

---

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)