Showing
1 changed file
with
20 additions
and
2 deletions
@@ -42,9 +42,10 @@ function initNavScroll(opt) { | @@ -42,9 +42,10 @@ function initNavScroll(opt) { | ||
42 | } | 42 | } |
43 | 43 | ||
44 | // 获取url中的参数 | 44 | // 获取url中的参数 |
45 | -function getUrlParam(name) { | 45 | +function getUrlParam(name, url) { |
46 | var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象 | 46 | var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象 |
47 | - var r = window.location.search.substr(1).match(reg); // 匹配目标参数 | 47 | + var urlTest = url || window.location.href; |
48 | + var r = urlTest.slice(urlTest.indexOf('?') + 1).match(reg); // 匹配目标参数 | ||
48 | 49 | ||
49 | // 返回参数值 | 50 | // 返回参数值 |
50 | if (r !== null) { | 51 | if (r !== null) { |
@@ -76,6 +77,20 @@ function activeNav() { | @@ -76,6 +77,20 @@ function activeNav() { | ||
76 | var $nav = $('#index_nav'); | 77 | var $nav = $('#index_nav'); |
77 | var index = getUrlParam('yh_channel'); | 78 | var index = getUrlParam('yh_channel'); |
78 | 79 | ||
80 | + // 判断是否有首页选项 | ||
81 | + var flag = false; | ||
82 | + | ||
83 | + $nav.find('li').each(function() { | ||
84 | + var $this = $(this); | ||
85 | + var url = $this.find('a').attr('href'); | ||
86 | + var code = getUrlParam('content_code', url); | ||
87 | + | ||
88 | + if (code === 'c19ffa03f053f4cac3690b22c8da26b7') { | ||
89 | + flag = true; | ||
90 | + return false; | ||
91 | + } | ||
92 | + | ||
93 | + }); | ||
79 | getOtherIndex(); | 94 | getOtherIndex(); |
80 | if (index === null) { | 95 | if (index === null) { |
81 | index = getUrlParam('type'); | 96 | index = getUrlParam('type'); |
@@ -85,6 +100,9 @@ function activeNav() { | @@ -85,6 +100,9 @@ function activeNav() { | ||
85 | $nav.find('li[data-type=' + index + ']').addClass('active').siblings().removeClass('active'); | 100 | $nav.find('li[data-type=' + index + ']').addClass('active').siblings().removeClass('active'); |
86 | } | 101 | } |
87 | } else { | 102 | } else { |
103 | + if (!flag) { | ||
104 | + index -= 1; | ||
105 | + } | ||
88 | $nav.find('li:not([data-nav="other"])').eq(index).addClass('active').siblings().removeClass('active'); | 106 | $nav.find('li:not([data-nav="other"])').eq(index).addClass('active').siblings().removeClass('active'); |
89 | } | 107 | } |
90 | 108 |
-
Please register or login to post a comment