Snow Studios Copyright, reprint please specify "http://blog.csdn.net/lina791211"
1. Preface
Pure JavaScript Settings homepage, add to Favorites.
2. Set Homepage
Set as Home function Sethome (obj, vrl) {try {obj.style.behavior = ' url (#default #homepage) '; Obj.sethomepage (VRL);} catch (E) {if (Window.netscape) {try {netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconnect");} catch (e) { Alert ("This action is rejected by the browser!") \ n Please enter "About:config" in the browser address bar and return to \ n then set the value of [Signed.applets.codebase_principal_support] to ' true ' and double click. ");} var prefs = components.classes[' @mozilla. Org/preferences-service;1 '].getservice ( Components.interfaces.nsIPrefBranch);p refs.setcharpref (' Browser.startup.homepage ', VRL);} else {alert ("Your browser does not support, follow these steps: 1. Open the browser settings. 2. Click on the Settings page. 3. Enter: "+ VRL +" click OK. ");}}}
3, add to the collection
Favorites compatible with 360 and ie6function Shoucang (Stitle, sURL) {try {window.external.addFavorite (sURL, stitle);} catch (e) {try {window . Sidebar.addpanel (Stitle, sURL, "");} catch (E) {alert ("Failed to bookmark, use Ctrl+d to add");}}
4. Get URL parameters
function Geturlparam (name) {var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)");//Constructs a regular expression object with a target parameter var r = Window.location.search.substr (1). Match (REG); Match Target parameter if (r! = null) return unescape (r[2]); return null; Return parameter Value}
5, solve the Chinese garbled
Send the Post page $ (' #simpleSearchButton '). Click (function () {var _k = $ (' #textfield '). Val (); var url = "; if (_k==null | | _k==" ") {//url = encodeURI (' <%=path%>/'); return;} Else{url = encodeURI (' <%=path%>/search.jsp?keyword= ' + _k);} url = encodeURI (URL);//<span style= "font-family:arial;" > Two encryption (encode may not succeed, use two times encode) </span>window.open (URL, ' _self ');});
Accept Parameters page//Use the method provided in section fourth window.onload = function () {var keyword = geturlparam (' keyword ');//get keyif (keyword = = null) keyword = "; keyword = decodeURI (decodeuri (keyword));//Two decryption (when encode is unsuccessful, two times encode is used, so two times decode) $ (" #textfield ") . val (keyword); simplequery (); $ ("#search_paging"). Show ();