That '70s Show spoofed Rear Window, along with other Hitchcock films, in season 3, episode 4's "Too Old to Trick or Treat, Too Young to Die" (originally aired October 31, 2000) [REF].
The 100th episode of Castle, S05 E19 "The Lives of Others" was a spoof featuring an injured Richard Castle, who is confined to his apartment and becomes obsessed after witnessing what he believes is a murder, but is actually a setup by his friends and family to celebrate his birthday.