Why is Javascript not working on page opened by redirect?

Viewed 38

I have a problem where a page that is opened as a result of a redirect call does not execute the javascript function. This page is simply a message to indicate that an OAuth2 user session has started so I want it to close right away. It is opened by the redirect initiated by the OAuth server after processing the access_token request.

If I access this page in testing it works fine:

System.Diagnostics.Process.Start("https://localhost:44302/Home/SessionOpen");

The page loads, closes in 2 seconds.

If it is opened via the redirect it never closes...

The dead simple page:

<body  onload="closeit();">
    <div style="margin-left:auto;margin-right:auto;">
        <h3>Session has started.</h3>
        <h4>If this window does not close automatically you may close it manually.</h4>

        <script type='text/javascript'>

            function closeit(){

                setTimeout(function() {
                 window.close();
               }, 2000);
            };

        </script>
    </div>
 </body>
1 Answers

Have you tried taking the javascript snippet out of the body ? I think that could be the solution

Related