JavaScript: Difference between revisions

Content deleted Content added
Reverted 1 edit by 94.43.5.59 (talk): Not significant enough. (TW)
Use in web pages: Updated with more modern examples
Line 275:
The most common use of JavaScript is to write functions that are embedded in or included from [[HTML]] pages and that interact with the [[Document Object Model]] (DOM) of the page. Some simple examples of this usage are:
 
* Loading new page content or submitting data to the server via [[AJAX]] without reloading the page (for example, a social network might allow the user to post status updates without leaving the page)
* Opening or [[Pop-up ad|popping up]] a new window with programmatic control over the size, position, and attributes of the new window (e.g. whether the menus, toolbars, etc., are visible).
* Animation of page elements, fading them in and out, resizing them, moving them, etc.
* Interactive content, for example games, and playing audio and video
* [[Data validation|Validating]] input values of a [[form (web)|web form]] to make sure that they are acceptable before being submitted to the server.
* Changing images as the mouse cursor [[Rollover (web design)|moves over them]]: This effect is often used to draw the user's attention to important links displayed as graphical elements.
* Transmitting information about the user's reading habits and browsing activities to various websites. Web pages frequently do this for [[web analytics]], [[ad tracking]], [[personalization]] or other purposes.<ref>{{cite web | url=http://piwik.org/docs/javascript-tracking/ | title=JavaScript tracking - Piwik | publisher=[[Piwik]] | accessdate=31 March 2012 17:56 (UTC)}}</ref>