Return to Snippet

Revision: 41412
at February 17, 2011 15:19 by giver


Updated Code
jQuery.fn.center = function() {
  this.css("position", "absolute");
  this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
  this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
  return this
};

Revision: 41411
at February 17, 2011 15:15 by giver


Updated Code
jQuery.fn.center = function() {
  this.css("position", "absolute");
  this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
  this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
  return this
};
var urlParams = {};
(function() {
  for(var a, b = /\+/g, c = /([^&;=]+)=?([^&;]*)/g, d = window.location.search.substring(1);a = c.exec(d);) {
    urlParams[decodeURIComponent(a[1].replace(b, " "))] = decodeURIComponent(a[2].replace(b, " "))
  }
})();

Revision: 41410
at February 17, 2011 15:11 by giver


Initial Code
jQuery.fn.center = function () {
                this.css("position","absolute");
                this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
                this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
                return this;
            }

            var urlParams = {};
            (function () {
                var e,
                a = /\+/g,  // Regex for replacing addition symbol with a space
                r = /([^&;=]+)=?([^&;]*)/g,
                d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
                q = window.location.search.substring(1);

                while (e = r.exec(q))
                    urlParams[d(e[1])] = d(e[2]);
            })();

Initial URL


Initial Description


Initial Title
jQuery Center Vertical and Horizontal Web Page

Initial Tags
jquery, center

Initial Language
jQuery