Snow Studios copyright All, reprint please specify "http://blog.csdn.net/lina791211"
1. Preface
Pure JavaScript Settings homepage, add 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 operation was 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 on it. ");} 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 this, follow these steps: 1. Open the browser settings.2. Click on the Settings page.
3. Enter: "+ VRL +" click OK. ");}}}
3. Add a collection
Add Favorites compatible 360 and Ie6function Shoucang (Stitle, sURL) {try {window.external.addFavorite (sURL, stitle);} catch (e) {try {window . Sidebar.addpanel (Stitle, sURL, "");} catch (E) {alert ("Add collection failed. Please use Ctrl+d to add ");}}}
4. Get URL parameters
function Geturlparam (name) {var reg = new RegExp ("(^|&)" + name + "= ([^&]*) (&|$)");//Constructs a regular table object with target parameters var r = Window.location.search.substr (1). Match (REG); Match Target parameter if (r! = null) return unescape (r[2]); return null; Returns the number of references}
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 the 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 (once encode is unsuccessful.) Use two times encode. So here it's going to be two times decode) $ ("#textfield"). val (keyword); simplequery (); $ ("#search_paging"). Show ();
Pure JS Set homepage, add favorites, get URL parameters, solve Chinese garbled