Solved

setting timers in javascript

Posted on 2004-08-17
12
237 Views
Last Modified: 2013-12-18
hi all,

I know this is simple but i am confused. I want to set a timer on a domino form. Once the time expires it should automatically take users back to a previous page.

any ideas?

thanks,

Jay.

0
Comment
Question by:jaggernat
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 11828162
keep this in JS Header:
var pathnameTmp = (window.location.pathname);
var pathname = pathnameTmp.toLowerCase();

function redirect() {
       // window.location.replace( "http://mail.yahoo.com")
       window.location.replace(pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+'welcomeform?OpenForm')
}

And in onload :
setTimeout("redirect();", 2000)
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 11828296
This is the example from the help.  Change the elapsedTimer sub to close the document
(
if elapsedTime > 300 then
dim ws as new notesuiworkspace
call ws.currentdocument.close()
end if
)

These declarations are in the (Globals) (Declarations) script for the form. The variable elapsedTime is used by various objects on the form. The NotesTimer object elapsedTimer must be in effect during the execution of a number of scripts on the form.
Dim elapsedTime As Integer
Dim elapsedTimer As NotesTimer
%INCLUDE "lsconst.lss"
When a document based on this form opens, the NotesTimer object is created with an interval of one second. An event handler for the Alarm event of the object is established.
Sub Postopen(Source As Notesuidocument)
  Set elapsedTimer = New NotesTimer(1, _
  "Elapsed time since opening document")
  elapsedTime = 0
  On Event Alarm From elapsedTimer _
  Call elapsedTimerHandler
End Sub
This user code is the event handler specified in the On Event statement above. It simply increments the global variable by 1 each time it is called.
Sub elapsedTimerHandler(Source As NotesTimer)
  elapsedTime = elapsedTime + 1
End Sub
This script is for a button on the form. The script displays the time accumulated in the global variable.
Sub Click(Source As Button)
  Dim etime As Integer
  Dim minutes As Integer
  etime = elapsedTime
  If etime < 60 Then
    Messagebox etime & " second(s)",, _
    "Elapsed time since opening document"
  Else
    minutes = 0
    Do While etime > 59
      minutes = minutes + 1
      etime = etime - 60
    Loop
    Messagebox minutes & " minute(s), " _
    & etime & " second(s)",, _
    "Elapsed time since opening document"
  End If
End Sub
This script queries the Enabled property of the NotesTimer object and toggles it if the user wants to.
Sub Click(Source As Button)
  If elapsedTimer.Enabled Then
    If Messagebox _
    ("Do you want to disable the timer?", _
    MB_YESNO + MB_ICONQUESTION, _
    "Elapsed timer is enabled") = IDYES Then
      elapsedTimer.Enabled = False
    End If
  Else
    If Messagebox _
    ("Do you want to enable the timer?", _
    MB_YESNO + MB_ICONQUESTION, _
    "Elapsed timer is disabled") = IDYES Then
      elapsedTimer.Enabled = True
    End If
  End If
End Sub
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 11828299
This will btw only work in the Notes client !
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 11828321
Ok. TOM
I will note your code if I want to use in client side.
but the initiator asked for JAVA SCRIPT.

And how you are doing Tom?
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 11828514
And if you want to change the timer value, then change it in onload event. (change 2000 to any value and use it according to your needs)
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 11829524
I must have misread the question ....
So I probably need glasses :-)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 10

Author Comment

by:jaggernat
ID: 11831322
Hi madheeswar,

Remember , my problem was, from the jobs  confirmation page , i wanted to go back to search results page.

and your solution was <<<<<   once the user clicks on search document, and applies, instead of having your msg in $$Return field, create a "thanksform" and in the $$Returnfield divert it to that form and in that form, we can place a timer and redirect to the search page like history.go(-3)
1->opendocument
2->editdocument
3->Thankyouform   >>>>>


This solution  works fine ..but i want to set a 15 second timer on the "thanksform"  before it goes back to search results page.

thanks,
Jay


thats why I used -3
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 11843094
Is this still awaiting response?


Put this code in the JS Header

function timeoutloopback() {
     if (history.length > 2) history.go(-3)
     else history.go(0-history.length)
}


And this in onLoad :
setTimeout("timeoutloopback();", 15000)
0
 
LVL 10

Author Comment

by:jaggernat
ID: 11843464
oh , i got the solution a couple of days back. thanks anyway.

Jay
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 11844937
Hey buddy, did you ask the question after having the solution ;-)
0
 
LVL 19

Accepted Solution

by:
madheeswar earned 350 total points
ID: 11849091
Jaggernat,
thats why I told u to create a Thankform and use it in $$Return field.

Is it solved or waiting response from me?

-Thanks.
0
 
LVL 10

Author Comment

by:jaggernat
ID: 11896213
no Ranjeet...

i meant , madheeswar's solution works just fine.

full points,

J
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now