---
title: "removeScriptMessageHandler(forName:contentWorld:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkusercontentcontroller/removescriptmessagehandler(forname:contentworld:)"
---

# removeScriptMessageHandler(forName:contentWorld:)

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

## Declaration

```swift
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 doc://com.apple.webkit/documentation/WebKit/WKContentWorld.

## See Also

### Adding and Removing Message Handlers

- [add(_:name:)](webkit/wkusercontentcontroller/add(_:name:).md)
- [add(_:contentWorld:name:)](webkit/wkusercontentcontroller/add(_:contentworld:name:).md)
- [addScriptMessageHandler(_:contentWorld:name:)](webkit/wkusercontentcontroller/addscriptmessagehandler(_:contentworld:name:).md)
- [removeScriptMessageHandler(forName:)](webkit/wkusercontentcontroller/removescriptmessagehandler(forname:).md)
- [removeAllScriptMessageHandlers(from:)](webkit/wkusercontentcontroller/removeallscriptmessagehandlers(from:).md)
- [removeAllScriptMessageHandlers()](webkit/wkusercontentcontroller/removeallscriptmessagehandlers().md)
- [WKScriptMessageHandler](webkit/wkscriptmessagehandler.md)
- [WKScriptMessageHandlerWithReply](webkit/wkscriptmessagehandlerwithreply.md)
