If the battery was dead or close to it, you could not turn on the ignition in the first place. So that will not work if the battery really needs charging.
And as others have said, the glovebox solenoid will clatter and use a lot of current turning ON and OFF continuously, plus all of the running lights, including the front incandescent types, run any time the ignition is on so the battery charger would have to provide enough current for all of those things and then an additional amount to actually charge the battery.
That said, you might be able to do it that way but I would think the glove box solenoid would burn up and cost more to replace than putting a whip on the battery that would charge even a dead battery anyway. Just my opinion but it seems like one of those things that will take some effort to [not do] the correct way.
Brian
Let's say the Ignition was turned On, and you connected the battery charger until the headlight turned On, then the battery would be fully charged safely?