Your code is a client event script which is Vision only. The system.nav.* functions are also vision only. Since you've tagged this Perspective and are switching views they won't work for you.
@dkhayes117 beat me to it, but the link might still be useful.