Fifk
Новичок
mod_rewrite и cookie (проблема с динамическим меню)
На сайте организовано динамическое меню. Состоит из 3-х разделов с ссылками:
меню 1: ссылка 1, ссылка 2;
меню 2: ссылка 2, ссылка 3, ссылка 4;
меню 3: ссылка 5.
Все 3 меню по умолчанию скрыты, раскрываются при нажатии. И здесь имеется такая тонкость: при раскрытии любого меню создается куки (посредством явы), чтобы при навигации по меню не приходилось его снова раскрывать.
http://pic.ipicture.ru/uploads/081115/thumbs/TcSuNfpmxZ.jpg
Код меню:
Код java-скрипта
Так вот. Если включить модуль mod_rewrite, то с этим меню творятся просто чудеса. При переходе по ссылкам, некоторые меню отображаются, некоторые нет, происходит путаница меню и ссылок (иногда происходит такое ощущение, что не меняется параметр куки). Как можно обойти такую проблему?
На сайте организовано динамическое меню. Состоит из 3-х разделов с ссылками:
меню 1: ссылка 1, ссылка 2;
меню 2: ссылка 2, ссылка 3, ссылка 4;
меню 3: ссылка 5.
Все 3 меню по умолчанию скрыты, раскрываются при нажатии. И здесь имеется такая тонкость: при раскрытии любого меню создается куки (посредством явы), чтобы при навигации по меню не приходилось его снова раскрывать.
http://pic.ipicture.ru/uploads/081115/thumbs/TcSuNfpmxZ.jpg
Код меню:
PHP:
<?
echo "
<table cellSpacing='0' cellPadding='0' border='1' width='165' align='center' bordercolor='#000000' bgcolor='#909DB4'>
<tr>
<td align='center' height='22'><a href='#' onclick=\"javascript: clickHandler('list1'); return false;\">меню 1</a></td>
</tr>
<tr>
<td valign='top'>
<div id='list1_details' style='position: relative;'>
<SCRIPT LANGUAGE='JavaScript'>
<!--
if (getCookie('mnp_list1') == 'none')
{
list1_details.style.display = '';
}
else
{
list1_details.style.display = 'none';
}
// -->
</SCRIPT>
<table cellSpacing='0' cellPadding='0' border='1' width='163' bordercolor='#FFFFFF' bgcolor='#e8e9ab'>
<tr>
<td height='22' onmouseover=this.style.backgroundColor='#f6f6ce' style='CURSOR: hand' onclick=window.location.href='/users_list/' onmouseout=this.style.backgroundColor='#e8e9ab' valign='center'> ссылка 1</td>
</tr>
<tr>
<td height='22' onmouseover=this.style.backgroundColor='#f6f6ce' style='CURSOR: hand' onclick=window.location.href='/users_add/' onmouseout=this.style.backgroundColor='#e8e9ab' valign='center'> ссылка 2</td>
</tr>
</table>
</div>
</td>
</tr>
<!-- [2] -->
<tr>
<td align='center' height='22'><a href='#' onclick=\"javascript: clickHandler('list2'); return false;\">меню 2</a></td>
</tr>
<tr>
<td valign='top'>
<div id='list2_details' style='position: relative;'>
<SCRIPT LANGUAGE='JavaScript'>
<!--
if (getCookie('mnp_list2') == 'none')
{
list2_details.style.display = '';
}
else
{
list2_details.style.display = 'none';
}
// -->
</SCRIPT>
<table cellSpacing='0' cellPadding='0' border='1' width='163' bordercolor='#FFFFFF' bgcolor='#e8e9ab'>
<tr>
<td height='22' onmouseover=this.style.backgroundColor='#f6f6ce' style='CURSOR: hand' onclick=window.location.href='/work_check/' onmouseout=this.style.backgroundColor='#e8e9ab' valign='center'> ссылка 3</td>
</tr>
<tr>
<td height='22' onmouseover=this.style.backgroundColor='#f6f6ce' style='CURSOR: hand' onclick=window.location.href='/work_ready/' onmouseout=this.style.backgroundColor='#e8e9ab' valign='center'> ссылка 4</td>
</tr>
<tr>
<td height='22' onmouseover=this.style.backgroundColor='#f6f6ce' style='CURSOR: hand' onclick=window.location.href='/work_false/' onmouseout=this.style.backgroundColor='#e8e9ab' valign='center'> ссылка 5</td>
</tr>
</table>
</div>
</td>
</tr>
<!-- [3] -->
<tr>
<td align='center' height='22'><a href='#' onclick=\"javascript: clickHandler('list3'); return false;\">меню 3</a></td>
</tr>
<tr>
<td valign='top'>
<div id='list3_details' style='position: relative;'>
<SCRIPT LANGUAGE='JavaScript'>
<!--
if (getCookie('mnp_list3') == 'none')
{
list3_details.style.display = '';
}
else
{
list3_details.style.display = 'none';
}
// -->
</SCRIPT>
<table cellSpacing='0' cellPadding='0' border='1' width='163' bordercolor='#FFFFFF' bgcolor='#e8e9ab'>
<tr>
<td height='22' onmouseover=this.style.backgroundColor='#f6f6ce' style='CURSOR: hand' onclick=window.location.href='/ac_login/' onmouseout=this.style.backgroundColor='#e8e9ab' valign='center'> ссылка 6</td>
</tr>
</table>
</div>
</td>
</tr>
</table>";
?>
PHP:
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function clickHandler(param)
{
var name, targetId, targetElement;
targetId = param + "_details";
targetElement = document.all(targetId);
if (targetElement.style.display == "none")
{
targetElement.style.display = "";
document.cookie = "mnp_" + param + "=none";
}
else
{
targetElement.style.display = "none";
document.cookie = "mnp_" + param + "=yes";
}
}