How to stop execution run-time and relocate 
Author Message
 How to stop execution run-time and relocate

I have a client-side script using ADO connection.  If the connection fails,
I want to redirect the user back to the login page, like this:

try
    {
    objConn.Open( ....opening details....);
    }
catch(exeption)
    {
    if( exeption.number == ........)
        {
        window.alert("Login failed, you will be redirected to the login
page");
        location.href = "login.asp"
        }
    }

The problem is, the script execution will continue on this page, with
consequent errors.  Relocation seems not to be instant when you execute the
'location.href = ....'

How do you instantly stop execution and relocate?



Fri, 21 Mar 2003 03:00:00 GMT  
 How to stop execution run-time and relocate

Just add return false and catch the call if it was called from within
another function

location.href="login.asp";
return false;

HTH
Joost Devos


Quote:
> I have a client-side script using ADO connection.  If the connection
fails,
> I want to redirect the user back to the login page, like this:

> try
>     {
>     objConn.Open( ....opening details....);
>     }
> catch(exeption)
>     {
>     if( exeption.number == ........)
>         {
>         window.alert("Login failed, you will be redirected to the login
> page");
>         location.href = "login.asp"
>         }
>     }

> The problem is, the script execution will continue on this page, with
> consequent errors.  Relocation seems not to be instant when you execute
the
> 'location.href = ....'

> How do you instantly stop execution and relocate?



Fri, 21 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Stopping code in the middle of execution

2. Stop Script Execution

3. How to stop execution of a script

4. how to stop script-execution on a web page

5. Script execution time

6. Design-Time license needed at run-time ?

7. Stop, Stop, Stop..... Please HELP (code included)

8. HTA: Yielding execution to the runtime?

9. flash file: how to stop multilple runs?

10. Stopping VBScript run by the ScriptControl

11. START/STOP/ displayed Services running on PC thu an ASP page

12. Script stops after WshShell.Run

 

 
Powered by phpBB® Forum Software