background preloader

JavaScript

Facebook Twitter

Window size and scrolling. Finding the size of the browser window Clue browser can only work out window width. Tkhtml Hv3 has the body/documentElement clientHeight/Width values reversed - versions before September 2007 also do not support innerHeight/Width, so they cannot work with this script. There are some constants available that give the document area of the window that is available for writing to. These will not be available until after the document has loaded and the method used for referencing them is browser specific. The available constants are: Provided by most browsers, but not Internet Explorer 8-, and even in Internet Explorer 9+, it is not available in quirks mode. Provided by many browsers, including Internet Explorer. Provided by most DOM browsers, including Internet Explorer. As you can see, the browsers seem to have settled on at least one reliable property; . The most accurate method I could come up with uses the following algorithm: Finding how far the window has been scrolled.

Manipulating the browser history | Mozilla Developer Network. The DOM window object provides access to the browser's history through the history object. It exposes useful methods and properties that let you move back and forth through the user's history, as well as -- starting with HTML5 -- manipulate the contents of the history stack. Traveling through history Moving backward and forward through the user's history is done using the back(), forward(), and go() methods.

Moving forward and backward To move backward through history, just do: window.history.back(); This will act exactly like the user clicked on the Back button in their browser toolbar. Similarly, you can move forward (as if the user clicked the Forward button), like this: window.history.forward(); Moving to a specific point in history You can use the go() method to load a specific page from session history, identified by its relative position to the current page (with the current page being, of course, relative index 0).

To move back one page (the equivalent of calling back()): Examples See also. Réaliser un héritage en JavaScript. Introduction La Programmation Orientée Objet (POO) offre l'avantage indéniable de fournir un code modulaire. En effet, celle-ci se base sur deux concepts que sont les niveaux de visibilité et l'héritage. Les niveau de visibilité sont un peu des moyens de protections pour sécuriser les classes. Il en existe quatre : Default : Seuls les entités de la classe et et les classes filles accédent aux éléments de la classePublic : Toutes les entités externes accédent aux éléments de la classe Private : Seuls les entités de la classe accédent aux éléments de la classeProtected : Seuls les classes filles accédent aux éléments de la classe Une fois ces barrières misent en place, on peut maintenant faire communiquer les classes entres elles.

Prenons un exemple concret : Nous utiliserons ici un point de vue géographique en se basant sur l'API d'OpenLayers est son concept de couche. Faire hériter une classe en JavaScript Il existe trois manières de faire hériter des classes en JS. Exemple 1 : Exemple 2 : Javascript - Apply et Call. Les objets/prototypes. ProgYSM Carte Développement Documentation Données Test Yan Morin Sign in JavaScript › Tutoriel Javascript › Les objets/prototypes Articles Les objets Introduction Puisque Javascript n'est pas un langage à proprement parlé Objet, puisque c'est un Langage Orienté Prototype (LOP), le concept d'objet peut être confus.

Néanmoins, le fait qu'il s'agit de construire des prototypes, la modification des objets peut être fait d'une manière très avancée. Construction Un prototype/objet est construit à l'aide d'une fonction de base. Function Cube() { } À cette fonction, on peut attribuer des attributs internes. function Cube ( taille ) { this.taille = taille; this.couleur = 'rouge'; } Comme vous pouvez le voir, le mot-clé "this" représente la fonction, objet ou prototype en lui-même. Initialisation Avec fonction-constructeur et l'opérateur new On peut initialiser un objet de plusieurs manières, soit appeler une fonction d'initialisation: var maVariableDuCube1 = new Cube ( 5 ) ; Sans opérateur new Méthode Attribut. Home - GitHub.