Securely hooks a script handler. Equivalent to hooksecurefunc() for script handlers; allows one to "post-hook" a secure handler without tainting the original.

The original handler will still be called, but the handler supplied will also be called after the original, with the same arguments. Return values from the supplied handler are discarded. Note that there is no API to remove a hook from a handler: any hooks applied will remain in place until the UI is reloaded.

If there was no prior script handler set, then this simply sets the new function as the handler for the script type.


ScriptObject:HookScript("scriptType", handler)


  • scriptType - Name of the script whose handler should be hooked (string)
  • handler - A function to be called whenever the script handler is run (function)


-- hooks the default UI's player frame to insert a chat link to the player's
-- most recently completed achievement when shift-clicked
function PlayerLink(self, button, down)
   if ( IsModifiedClick("CHATLINK") ) then
      local link = GetAchievementLink(select(1,GetLatestCompletedAchievements()))
      ChatEdit_InsertLink (link)
PlayerFrame:HookScript("OnClick", PlayerLink)