What is a procrastination in JavaScript

JavaScript - Deferred code execution

window p.726 The comprehensive reference work

A browser window or frame

overview

  • self
  • window
  • window.frame [1]

properties

Methods

Event handler

  • onblur
  • onerror
  • onfocus
  • onload
  • onmove
  • onresize
  • onunload

window.alert () p.731 The comprehensive reference work

Displays a message in a dialog box

overview

Arguments

  • report

    The simple text string (not HTML) that will appear in a dialog box that opens about window appears.

window.prompt () p.749 The comprehensive reference work

Displays an input dialog

overview

  • window.prompt (message, default)

Arguments

  • report

    The simple string of text (not HTML) to display in a dialog box. It should ask the user to enter the desired data.

  • default

    A string that appears as standard input in the dialog box. e.g. empty string ""

Return value

The string entered by the user, the empty string if the user did not enter anything, or null if the user clicked Cancel.

Example of using prompt ()

window.setTimeout () p.754 The comprehensive reference work

Postpones code execution (in time)

overview

  • window.setTimeout (code, deferment)

Arguments

  • code

    A string of JavaScript code that follows postponement should be executed.

  • postponement

    The milliseconds that should elapse before the JavaScript instructions in the string code are executed.

Return value

A value ("timeout id") that you supply clearTimeout () can pass to the execution of code to prevent.

window.clearTimeout () p.734 The comprehensive reference work

Deletes a program execution that has been postponed

overview

  • window.clearTimeout (timeoutId)

Arguments

  • timeoutId

    A value returned by setTimeout () indicating which timeout to clear.

Code execution delay

Example:

<script type="text/javascript">

setTimeout ("giveMessage ();", 3000);

function giveMessage () {

alert ("Another three seconds past!");

}

</script>

back