Skip to content

Instantly share code, notes, and snippets.

@waitingallday
Created June 18, 2014 06:22
Show Gist options
  • Save waitingallday/76b72273601cb2836d02 to your computer and use it in GitHub Desktop.
Save waitingallday/76b72273601cb2836d02 to your computer and use it in GitHub Desktop.
Defeat the hash #
form = document.querySelector("form");
form.addEventListener("submit", function(event) {
e.preventDefault();
window.location = this.action + "#q=" + this.elements[1].value
}
// or you could wrap it in a domready container ie.
var domReady = function() {
n = document.querySelector("form"), n.addEventListener("submit", function(e) {
return e.preventDefault(), window.location = this.action + "#gsc.q=" + this.elements[1].value
});
};
window.attachEvent ? window.attachEvent("onload", domReady) : document.addEventListener("DOMContentLoaded", domReady, !1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment