Please check my code in Chrome Browser, if you hit refresh you will be prompted with 2 options.
Leave This Page and Stay on This Page>
Please use these lines of code , it works properly.