помогите с меню
только начинаю разбираться с javascript
надо сделать меню, помогите, пожалуйста, разобраться. как сделать так, чтобы не писать для каждого подменю отдельно функцию. и еще.. при загрузке страницы меню открыто, то есть все подменю открыты и только потом уже сворачиваются при том условии, что прописаны. как сделать так, чтобы при загрузке страницы меню было свернутым. не знаю, понятно ли объяснил. зарание спасибо. <style> #form-container {display: none} </style> <table> <tr> <td> <table id="menu" align="top" > <tr><td ><p><a href="" class="a2">aaa</a></p></td> </tr> <tr><td><p></p></a></td></tr> <tr> <td ><a href="" class="a2" id="trigger()" onmouseover="#form-container">bbb</a> <table id="form-container()" align="top" class="podmenu"> <tr><td ><p><a href="" class="podmenu2">- 111</a></p></td></tr> <tr><td ><p><a href="" class="podmenu2">- 222</a></p> </td></tr> <tr><td ><p><a href="" class="podmenu2">- 333</a></p></td></tr> <tr><td ><p><a href="" class="podmenu2">- 444</a></p> </td></tr> </table> </td> </tr> <tr><td><p></p></a></td></tr> <tr> <td ><a href="" class="a2" id="triggerr()" onmouseover="#form-container">ccc</a> <table id="form-containerr()" align="left" class="podmenu"> <tr><td ><p><a href="" class="podmenu2">- 111</a></p></td></tr> <tr><td ><p> <a href="" class="podmenu2">- 222</a></p></td></tr> </table> </td> </tr> <tr><td><p></p></a></td></tr> <tr> <td ><a href="" class="a2" id="triggerrr()" onmouseover="#form-container">ddd</a> <table id="form-containerrr()" align="left" class="podmenu"> <tr><td ><p><a href="" class="podmenu2">- 111</a></p></td></tr> <tr><td ><p><a href="" class="podmenu2">- 222</a></p></td></tr> <tr><td ><p> <a href="" class="podmenu2">- 333 </a></p></td></tr> </table> </td> </tr> <tr><td><p></p></a></td></tr> <tr> <td ><a href="" class="a2" id="triggerrrr()">eee</a> <table id="form-containerrrr()" align="left" class="podmenu"> <tr><td ><p><a href="" class="podmenu2">- 111</a></p></td></tr> <tr><td ><p> <a href="" class="podmenu2">- 222</a></p></td></tr> </table> </td> </tr> <tr><td><p></p></a></td></tr> <tr><td ><a href="" class="a2">fff</a></td></tr> <tr><td><p></p></a></td></tr> <tr><td ><a href="" class="a2">ggg</a></td></tr> </table> </td> </tr> </table> <script language="JavaScript"> document.getElementById('form-container()').onmouseout = function() { setTimeout(function(){ thisObj.form-container(toPass)}, 5000); document.getElementById('form-container()').style.display = 'none'; }; document.getElementById('trigger()').onmouseover = function() { var thisObj = this; var toPass = this.m_c; document.getElementById('form-container()').style.display = 'block'; setTimeout(function(){ thisObj.form-container(toPass)}, 5000); }; document.getElementById('form-container()').onmouseover = function() { document.getElementById('form-container()').style.display = 'block'; }; //============================= document.getElementById('triggerr()').onmouseover = function() { document.getElementById('form-containerr()').style.display = 'block'; setTimeout("function()", 5000); }; document.getElementById('form-containerr()').onmouseover = function() { document.getElementById('form-containerr()').style.display = 'block'; }; document.getElementById('form-containerr()').onmouseout = function() { setTimeout("function()", 5000); document.getElementById('form-containerr()').style.display = 'none'; }; //============================= document.getElementById('triggerrr()').onmouseover = function() { document.getElementById('form-containerrr()').style.display = 'block'; setTimeout("function()", 5000); }; document.getElementById('form-containerrr()').onmouseover = function() { document.getElementById('form-containerrr()').style.display = 'block'; }; document.getElementById('form-containerrr()').onmouseout = function() { setTimeout("function()", 5000); document.getElementById('form-containerrr()').style.display = 'none'; }; //============================= document.getElementById('triggerrrr()').onmouseover = function() { document.getElementById('form-containerrrr()').style.display = 'block'; setTimeout("function()", 5000); }; document.getElementById('form-containerrrr()').onmouseover = function() { document.getElementById('form-containerrrr()').style.display = 'block'; }; document.getElementById('form-containerrrr()').onmouseout = function() { setTimeout("function()", 5000); document.getElementById('form-containerrrr()').style.display = 'none'; }; //=============================== function getBodyScrollTop(){ return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop); } function pos_leftBar(){ document.getElementById('left_bar').style.paddingTop = (getBodyScrollTop()+20); } </script> |
Часовой пояс GMT +3, время: 20:42. |