Skip to content

Instantly share code, notes, and snippets.

@oliger
oliger / uri.js
Created September 6, 2012 14:43 — forked from jlong/uri.js
URI Parsing with Javascript
var parseUrl = (function() {
var parser = document.createElement('a');
return function(url) {
parser.href = url;
return {
hash: parser.hash,
host: parser.host,
hostname: parser.hostname,

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.