Category Archives: Javascript

Javascript redirect

// similar behavior as an HTTP redirect - prevents endless back button
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

Referenced from
http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript?rq=1

Javascript namespace notation

var namespace = new function() {
var privatestring = “abc”;
this.publicstring = “def”;
var privatefn = function () {};
this.publicfn = function() {};
};

Typically will have a public function called ‘init’ so that can call namespace.init();