$(function () { /**导航选中**/ var getcookie = function (sname) { var acookie = document.cookie.split("; "); for (var i = 0; i < acookie.length; i++) { var acrumb = acookie[i].split("="); if (sname == acrumb[0]) return unescape(acrumb[1]); } return null; } var oid = getcookie("oid");//导航栏选中 var sid = getcookie("sid");//侧边栏选中 var cid = getcookie("cid");//侧边栏选中 if (oid != undefined) { $(".under_ul li").each(function () { var $this = $(this); if ($this.attr(oid) != undefined) { $(this).addclass("on"); } }) } if (oid != undefined) { $("#pbnav li").each(function () { var $this = $(this); if ($this.attr(oid) != undefined) { $(this).addclass("active"); } }) } ///下拉选中 if (sid != undefined) { $(".drop_down li").each(function () { var $this = $(this); if ($this.attr(sid) != undefined) { $this.addclass("on"); } }) } if (sid != undefined) { $(".c_submenu li ").each(function () { var $this = $(this); if ($this.attr(sid) != undefined) { $this.addclass("on"); } }) } ///侧边栏选中s if (sid != undefined) { $(".nav_ul li").each(function () { var $this = $(this); if ($this.attr(sid) != undefined) { $this.addclass("on"); } }) } //if (cid != undefined) { // $("div.bd ul.clearfix li a").each(function () { // var $this = $(this); // if ($this.attr(cid) != undefined) { // $this.addclass("its"); // } // }) //} }); jquery.cookie = function (name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options = $.extend({}, options); options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toutcstring)) { var date; if (typeof options.expires == 'number') { date = new date(); date.settime(date.gettime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toutcstring(); } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeuricomponent(value), expires, path, domain, secure].join(''); } else { var cookievalue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jquery.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookievalue = decodeuricomponent(cookie.substring(name.length + 1)); break; } } } return cookievalue; } }; $(function () { $("#searchbutton").click(function () { var str = $("#textfield").val(); if (str == "请输入搜索关键词" || str == "") { layer.msg('请输入您想搜索的信息', { icon: 5 }); return; } else { var url = rootpath + "/search/"; $.cookie('ss_cookie', str, { path: '/' }); window.open(url); } }); });