Solved

setting timers in javascript

Posted on 2004-08-17
12
243 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 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