Friday, February 28, 2014

Hello! antique Use the following function that counts the time:


Hello! antique Use the following function that counts the time: <script language="JavaScript"> <! - Var countDownTime = 5; var z = ""; antique function countDown () {- countDownTime; if (countDownTime == 0) {countDownTime = 5, / / start another function whose result I need showHint (z); setTimeout ("countDown ()", 1000);} else {setTimeout ("countDown ()", 1000);}} / / -> < / script> <script antique language="JavaScript"> antique <! - setTimeout ("countDown ()", 1000); / / -> </ script> It is my countdown does not run when the user is viewing the contents of another window. When the window is in focus again, the function is activated again, passing off as the value of countDownTime = 1 (so you can immediately call showHint (z);-out is a note in the script) antique and then counting to continue standard. Thanks in advance! Back to top
<script> window.onfocus = function () {/ / executed when the main window is focused alert ('Hi');} window.onblur = function () {/ / executed when the main window lost the focus alert ('Buy ');} </ script> Back to top
Kimvaras, thank you addressed the topic! antique I feel that it is right as a solution because with <body onFocus="neshto si" onBlur="drugo neshto"> as the sample I tested is too low (need objects of the highest order - window as shown), but I think that what you suggest something is missing. I tried it as a code, I do not pull Alerts, sample and display a value not displayed. How to get him, because obviously I do not? Inetersuva me a check, something like: if (a == b) {showHint (z);} Could you explain to me the basis of this example, and I'll adjust antique it to the needs?
Eti one example of how react: <html> <head> <script> var bFocus = false; window.onfocus = function () {if (bFocus) return; bFocus = true; / / user code document.getElementById ('ta') . value + = 'Focus \ n';} window.onblur = function () {if (! bFocus) return; bFocus = false; / / user code document.getElementById ('ta'). value + = 'Blur \ n ';} </ script> </ head> <body> <textarea id='ta' rows='20' cols='100'> </ textarea> </ body> </ html> Firefox a little carried away and cry onFocus and onBlur 2 times so there flag bFocus, to avoid a recall. Back to top
Hello! I drove the code (is valuable and will use it in other cases), but I encountered the same situation as the inquiry in body-tag. In IE, if you activate any element (eg tekstarea, wild, sleep-tag) window out of focus, even though it is active. In FF the problem is the opposite - if activated tekstarea or text box window remains active, even if it is minimized. If you gave similar reactions may hold tekstareata antique (a key element in the project) continuous focus and check on her, but in FF it confuses things. At my level Js problem seems unsolvable. In order not to spend extra CPU time, you will need to look for a compensating mechanism server Can you think of any other type of inspection? Back to top


No comments:

Post a Comment