User:ApolloCreed/search-focus.js

/* This javascript sets focus once the page has been loaded. If we are editing an article, focus goes to the article edit box, otherwise focus goes to the search box. If we are loading a page with a bookmark (url has a #), do not set focus.

// Set focus to search input function searchFocus(e) { wpTextbox1 = document.getElementById('wpTextbox1'); searchInput = document.getElementById('searchInput'); if (wpTextbox1) { if(/#/.test(window.location.href)) { return; }   wpTextbox1.focus; } else if (searchInput) { searchInput.focus; } return false; }

function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function { oldonload; func; } } }

addLoadEvent(searchFocus);