What is the origin of the knock-knock joke?

Some claim they originated in the Middle Ages as a call-and-answer password format. Others, as @Callithumpian notes, cite passages in Shakespeare.

Here is a legitimate reference to their existence in America in 1936:

enter image description here

This is the first legitimate printed reference I can find.


I found this use of the joke in the printed "Proceedings" of the American Pomological Society. This publication seems to cover meetings from 1933 to 1937, but this occurrence is early enough (p. 75) that I think it can be dated to 1933. I wondered if this was perhaps used as a jingle by an apple company, but I couldn't find evidence of this.

http://books.google.com/books?ei=sNIFToedJs-10AGVktz_Cg&ct=result&id=DGwPAQAAIAAJ&dq=proceedings+american+pomological+society+1933&q=knock+knock#search_anchor

Whatever the origin of the first joke, its form certainly came from Macbeth:

http://books.google.com/books?id=rIE7AAAAYAAJ&printsec=frontcover&dq=macbeth+shakespeare&hl=en&ei=Y8oFTqLxOYfHgAe8-fHLDQ&sa=X&oi=book_result&ct=result&resnum=2&ved=0CDYQ6AEwAQ#v=onepage&q=knock%20knock&f=false