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

# removeScriptMessageHandler(forName:)

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

## Declaration

```swift
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

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

## 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:contentWorld:)](webkit/wkusercontentcontroller/removescriptmessagehandler(forname:contentworld:).md)
- [removeAllScriptMessageHandlers(from:)](webkit/wkusercontentcontroller/removeallscriptmessagehandlers(from:).md)
- [removeAllScriptMessageHandlers()](webkit/wkusercontentcontroller/removeallscriptmessagehandlers().md)
- [WKScriptMessageHandler](webkit/wkscriptmessagehandler.md)
- [WKScriptMessageHandlerWithReply](webkit/wkscriptmessagehandlerwithreply.md)
