This is a feature which is strangely lacking from Safari.
Luckily, here’s a script which will do the job.