centerInClient jQuery Plugin

This simple plug-in centers the content of the selected elements in the viewport or optionally in the specified container element.

jQuery.fn.centerInClient = function(options)

Options

The options parameter can be a map of any of these properties (default values are shown):

var opt = { forceAbsolute: false, container: window, // selector of element to center in completed: null };

forceAbsolute
Forces the selected elements to document absolute level. Use this option if the element doesn't center correctly which can happen if its position is relative already. When set the element is removed from its current hierarchy and moved to a child of body.

container
The element in which the selected element(s) are centered. Defaults to the window/viewport. Provide as a jQuery selector.

completed
Optional event handler that is fired when centering is completed. The called handler receives the element that is to be centered as a parameter.


Simple centering

$("#divMessage").centerInClient(); // centers in window

Center in another element

$("#imgLoading").centerInClient( { container: $("#divCustomerPanel") });

Class Members

Requirements

See also:

Class modalDialog

  Last Updated: 10/21/2008 | © West Wind Technologies, 2008