Solved

setting timers in javascript

Posted on 2004-08-17
12
240 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

13 Experts available now in Live!

Get 1:1 Help Now