Active Accordeon菜单不适用于带有查询字符串的子链接 [英] Active Accordeon Menu don't work with sublinks with query strings
问题描述
@Ejay如果我在此链接的某些子链接中单击,请帮助我设置打开主链接。
我进行了一些修改,例如:
< script type = text / javascript>
$ {document).ready(function(){
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/' )+ 1);
var url = sPage.split('?')[0];
$('dd')。filter(function(){
return $('a [href ='+ url +']',$(this))。length == 0
})。hide();
$('dt a.submenu')。click(function(){
$( dd:visible)。slideUp( slow);
$(this).parent()。next ('dd')。slideDown( slow);
返回false;
});
});
< / script>
该脚本仅在我的链接为
<时有效pre>
< a href = test.asp> TESTE< / a>
如果我的链接是这样的:< a href = test。 asp?category = BLABLABLA> BLABLABLA< / a>
这不起作用。
出什么问题了
可以在此处部分查看菜单: http://alsite.com .br / saks_div /
如果
var sPath = window.location.pathname;
适用于类似 abc.asp
的URL以下应与具有查询字符串的URL一起使用,例如 produtos_categoria.asp?categoria = something
var sPath = window.location.pathname + window.location.search;
@Ejay Help me to set "opened" the main link if i click iin some sublinks of this...
here: Set "active" accordion menu after click
i make some modifications like:
<script type="text/javascript">
$(document).ready(function(){
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
var url = sPage.split('?')[0];
$('dd').filter(function () {
return $('a[href="' + url + '"]', $(this)).length == 0
}).hide();
$('dt a.submenu').click(function () {
$("dd:visible").slideUp("slow");
$(this).parent().next('dd').slideDown("slow");
return false;
});
});
</script>
This script only works if my link is
<a href="test.asp">TESTE</a>
if my link is that way: <a href="test.asp?category=BLABLABLA">BLABLABLA</a>
this don't work..
what is wrong
Can see the menu working partly here: http://alsite.com.br/saks_div/
if
var sPath = window.location.pathname;
works for URL's like abc.asp
then following should work with URL's having a query string, e.g., produtos_categoria.asp?categoria=something
var sPath = window.location.pathname+window.location.search;
这篇关于Active Accordeon菜单不适用于带有查询字符串的子链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!