wixLocation.to("http://wix.com") not working !

@jonatandor35 Thanks J.D, You’re actually right , I’m trying in preview mode instead and as you said code I tried code in Live mode which is working fine as expected.
Not sure how code is actually working fine in Live mode but not in preview mode?
Thanks