Skip to content

Instantly share code, notes, and snippets.

@hemanth
Created August 6, 2013 15:31
Show Gist options
  • Save hemanth/6165556 to your computer and use it in GitHub Desktop.
Save hemanth/6165556 to your computer and use it in GitHub Desktop.
WHATWG URL API

WHATWG URL API

script - unit tests - draft spec - See script for cross-browser quirks

var url = new URL(url, base);
var value = url.getParameter(name);
var valueArray = url.getParameterAll(name);
url.appendParameter(name, valueOrValues);
url.clearParameter(name);
var nameArray = url.parameterNames;

URL objects have properties:

  • protocol
  • host
  • hostname
  • port
  • pathname
  • search
  • hash
  • filename
  • href
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment