Although "Where Did You Get That Hat?" was popular in the English music hall, and the lyrics as printed in the above publication have a parochial feel, the original was actually written by the American performer Joseph Sullivan in 1888. According to The Tin Pan Alley Song Encyclopedia
, Sullivan found an old top hat while going through his late father's effects, and when he wore it in the street a young boy accosted him with the six words that would pass into the English language as a catchphrase.
The melody is based partly on a leitmotiv from Wagner's Lohengrin
, which was "another inside joke" at that time, and the song was sung by Gene Kelly in the 1949 film Take Me Out To The Ball Game
. It was also recorded by the English comedian Stanley Holloway. (thanks, Alexander Baron - London, England, for above 2)