Click here to Skip to main content
15,888,521 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionAny body know the basic components to a javascript slideshow? Pin
swydell30-Oct-11 14:43
swydell30-Oct-11 14:43 
AnswerRe: Any body know the basic components to a javascript slideshow? Pin
Manfred Rudolf Bihy30-Oct-11 22:59
professionalManfred Rudolf Bihy30-Oct-11 22:59 
QuestionStop Text From Being Converted Into Links Pin
ASPnoob28-Oct-11 23:32
ASPnoob28-Oct-11 23:32 
AnswerRe: Stop Text From Being Converted Into Links Pin
Richard MacCutchan29-Oct-11 0:06
mveRichard MacCutchan29-Oct-11 0:06 
AnswerRe: Stop Text From Being Converted Into Links Pin
Dennis E White29-Oct-11 15:13
professionalDennis E White29-Oct-11 15:13 
QuestionIssue w/ Javascript inside 64 bit browser Pin
bgates197026-Oct-11 5:26
bgates197026-Oct-11 5:26 
AnswerRe: Issue w/ Javascript inside 64 bit browser Pin
Dennis E White27-Oct-11 9:08
professionalDennis E White27-Oct-11 9:08 
AnswerRe: Issue w/ Javascript inside 64 bit browser Pin
jsc4228-Oct-11 1:38
professionaljsc4228-Oct-11 1:38 
One possibility is that other task running in the machine are killing the setInterval - this happens very often in Internet Explorer to the extent that the standard advice is to never use setInterval but to use setTimeout even though it is slightly more difficult.

If you are running in a 64 bit processor, then I guess that performance is not an issue. But there are a few places where the JavaScript could be improved.
* The only way that the secondsRemaining can go negative is if you run startAutoLogoff twice as you initialise the secondsRemaining at the top and not at the start of the auto logoff and you test for that condition.
* There is a -= 1 idiom: it is the pre-/post-decrement operator (--). Just because some gurus don't like it in the middle of expressions, does not mean that it is verbotem as a stand alone construct.
* Since JavaScript 1.2 (c 1998), the setInterval and setTimeout methods have supported functions as arguments as an alternative to expressions. These are more efficient, support closures, and prevent faux eval expressions which most gurus hate.
* You have a lot of global variables (secondsRemaining, mhcTimer, countDown, and startAutoLogoff). It is possible that you may have a name clash somewhere else in your code that is causing the issue that you describe.

Here is my equivalent code (I know that my layout and style offend some people):
C#
function    startAutoLogoff()
{
    if  (! startAutoLogoff.mhcTimer)    // Timer is not active
    {
        startAutoLogoff.secsRemaining   =
            startAutoLogoff.timeoutTime;    // No of secs to wait

        startAutoLogoff.mhcTimer    =
            window.setTimeout( startAutoLogoff.countDown, 1000 );
    }   // if
}   // startAutoLogoff


startAutoLogoff.countDown   =   // Support routine for timing down
    function( )
    {
        if  (--startAutoLogoff.secsRemaining)   // Timed out?
            startAutoLogoff.mhcTimer    =   // No. Keep waiting
                window.setTimeout( startAutoLogoff.countDown, 1000 );
        else    // Yes. Logoff
            window.location ='login.aspx';
    };  // startAutoLogoff.countDown

//  Static properties used by startAutoLogoff
startAutoLogoff.mhcTimer    = false;
startAutoLogoff.timeoutTime = 30;
startAutoLogoff.secsRemaining   = startAutoLogoff.timeoutTime;

startAutoLogoff();

QuestionHTMLInput.name Pin
Ali Al Omairi(Abu AlHassan)25-Oct-11 21:40
professionalAli Al Omairi(Abu AlHassan)25-Oct-11 21:40 
AnswerRe: HTMLInput.name Pin
Gerben Jongerius25-Oct-11 22:10
Gerben Jongerius25-Oct-11 22:10 
GeneralRe: HTMLInput.name Pin
Ali Al Omairi(Abu AlHassan)25-Oct-11 23:41
professionalAli Al Omairi(Abu AlHassan)25-Oct-11 23:41 
QuestionJavascript validate the master and content page Pin
sathyan_829423-Oct-11 2:45
sathyan_829423-Oct-11 2:45 
AnswerRe: Javascript validate the master and content page Pin
DaveAuld23-Oct-11 3:41
professionalDaveAuld23-Oct-11 3:41 
AnswerRe: Javascript validate the master and content page Pin
MalarGayu9-Nov-11 15:33
MalarGayu9-Nov-11 15:33 
QuestionWhere is the data behind the page? Pin
LeonardoDaga22-Oct-11 0:37
LeonardoDaga22-Oct-11 0:37 
AnswerRe: Where is the data behind the page? Pin
Richard MacCutchan22-Oct-11 1:48
mveRichard MacCutchan22-Oct-11 1:48 
GeneralRe: Where is the data behind the page? Pin
LeonardoDaga22-Oct-11 6:12
LeonardoDaga22-Oct-11 6:12 
GeneralRe: Where is the data behind the page? Pin
Richard MacCutchan22-Oct-11 6:26
mveRichard MacCutchan22-Oct-11 6:26 
GeneralRe: Where is the data behind the page? Pin
DaveAuld22-Oct-11 8:21
professionalDaveAuld22-Oct-11 8:21 
GeneralRe: Where is the data behind the page? Pin
Richard MacCutchan22-Oct-11 21:51
mveRichard MacCutchan22-Oct-11 21:51 
GeneralRe: Where is the data behind the page? Pin
DaveAuld22-Oct-11 21:59
professionalDaveAuld22-Oct-11 21:59 
GeneralRe: Where is the data behind the page? Pin
Richard MacCutchan23-Oct-11 2:17
mveRichard MacCutchan23-Oct-11 2:17 
GeneralRe: Where is the data behind the page? Pin
DaveAuld24-Oct-11 4:50
professionalDaveAuld24-Oct-11 4:50 
GeneralRe: Where is the data behind the page? Pin
Richard MacCutchan24-Oct-11 5:16
mveRichard MacCutchan24-Oct-11 5:16 
GeneralRe: Where is the data behind the page? Pin
AspDotNetDev23-Oct-11 8:24
protectorAspDotNetDev23-Oct-11 8:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.