Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

setting timers in javascript

Posted on 2004-08-17
12
Medium Priority
?
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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.

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
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

722 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