Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

setting timers in javascript

Posted on 2004-08-17
12
Medium Priority
?
249 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

972 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