I have simulated this circuit with 5V zener and it works fine. In the output I will connect the optocoupler.
View attachment 127427
That won't detect the DC.
The problem is that any linear circuit with only resistors that will make sure that the HCPL-3700 operates at 12 V will allow too much current at 240 V.
Assuming that the higher voltages that you need the circuit to detect are ac, then a series capacitor will do exactly the wrong thing, and give you more current with ac. You could put a capacitor in parallel, to bypass current from the HCPL-3700 on ac.
A series inductor would be ideal, but you would need an enormous value of inductor, so it would not be at all practical.
You could limit the voltage with a zener, and then have a second resistor to limit the current to the HCPL-3700 but the first resistor and the zener would produce a lot of heat.
There would be some advantage in having a diode in series, if you are happy that the circuit won't detect negative voltages. You might need a larger capacitor, but the heat generated on ac would be halved.
AnalogKid's circuit is probably the best approach. It would need a diode or a bridge rectifier before it.