Breathe through your mouth. Hold a match in your teeth. And plenty of others that work just as badly...
The fact is, a pungent yellow cooking onion appears to attack the eyeballs directly, and the easiest way to avoid the pain is simply to wear a pair of goggles.
However, ordinary safety goggles don't cut it - they are ventilated, and that onion gas streams right in. You need a pair of unventilated goggles. Brazing goggles are perfect, and of course they are much better if you do them up in steampunk style.
Surprisingly, with goggles on, I can take a huge hoot of onion vapor right up the nose, with no pain or effect other than "that smells very oniony." It appears onions, or at least cheap yellow onions, directly attack the eyes from the outside.
Step 1: Why Not Hang Them in Your Kitchen?
You can also use them to protect your eyes against steam, in case of a pressure-cooker explosion :)