首先增加一个脚本库,可以是Zepto或者jQuery的,然后获取之后使用switch进行分流处理
<script type="text/javascript" src="/Res/Scripts/zepto.js"></script> <script type="text/javascript"> function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } var type = getQueryString("type"); switch (type) { case "check": $("#ctl00_ContentPlaceHolder1_tab0").addClass("active"); break; case "used": $("#ctl00_ContentPlaceHolder1_tab1").addClass("active"); break; case "expired": $("#ctl00_ContentPlaceHolder1_tab2").addClass("active"); break; default: $("#ctl00_ContentPlaceHolder1_tab0").addClass("active"); } </script>