Use ```location.protocol``` instead.