首页 »Javascript教程 » js全局变量:利用js跨页面保存变量做菜单的思路方法 »正文js全局变量:利用js跨页面保存变量做菜单的思路方法来源: 发布时间:星期六, 2008年12月27日 浏览:79次 评论:0
最近公司在做
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 我想到 ![]() 1.利用cookies或session ![]() ![]() ![]() ![]() ![]() ![]() ![]() 2.利用history或navigator来建立这么 ![]() ![]() ![]() ![]() ![]() <script type="text/JavaScript"> <!-- function foc ![]() document.getElementById("searchkey").focus ![]() } //这是做搜索时 ![]() ![]() function init ![]() ![]() ![]() ![]() ![]() { history.dmenu=1; } //如果history.dmenu没有定义则设置为1即显示首页按扭 ![]() switch(history.dmenu){ ![]() { //alert(history.dmenu); document.getElementById("d_id1").src="/images/anB1.g ![]() document.getElementById("d_id2").src="/images/anB2.g ![]() document.getElementById("d_id3").src="/images/anB3.g ![]() document.getElementById("d_id4").src="/images/anB4.g ![]() document.getElementById("d_id5").src="/images/anB5.g ![]() document.getElementById("d_id6").src="/images/anB6.g ![]() ![]() ![]() { //alert(history.dmenu); document.getElementById("d_id1").src="/images/anB11.g ![]() document.getElementById("d_id2").src="/images/anB22.g ![]() document.getElementById("d_id3").src="/images/anB3.g ![]() document.getElementById("d_id4").src="/images/anB4.g ![]() document.getElementById("d_id5").src="/images/anB5.g ![]() document.getElementById("d_id6").src="/images/anB6.g ![]() ![]() } ![]() { document.getElementById("d_id1").src="/images/anB11.g ![]() document.getElementById("d_id2").src="/images/anB2.g ![]() document.getElementById("d_id3").src="/images/anB33.g ![]() document.getElementById("d_id4").src="/images/anB4.g ![]() document.getElementById("d_id5").src="/images/anB5.g ![]() document.getElementById("d_id6").src="/images/anB6.g ![]() ![]() } ![]() { document.getElementById("d_id1").src="/images/anB11.g ![]() document.getElementById("d_id2").src="/images/anB2.g ![]() document.getElementById("d_id3").src="/images/anB3.g ![]() document.getElementById("d_id4").src="/images/anB44.g ![]() document.getElementById("d_id5").src="/images/anB5.g ![]() document.getElementById("d_id6").src="/images/anB6.g ![]() ![]() } ![]() { document.getElementById("d_id1").src="/images/anB11.g ![]() document.getElementById("d_id2").src="/images/anB2.g ![]() document.getElementById("d_id3").src="/images/anB3.g ![]() document.getElementById("d_id4").src="/images/anB4.g ![]() document.getElementById("d_id5").src="/images/anB55.g ![]() document.getElementById("d_id6").src="/images/anB6.g ![]() ![]() } ![]() { document.getElementById("d_id1").src="/images/anB11.g ![]() document.getElementById("d_id2").src="/images/anB2.g ![]() document.getElementById("d_id3").src="/images/anB3.g ![]() document.getElementById("d_id4").src="/images/anB4.g ![]() document.getElementById("d_id5").src="/images/anB5.g ![]() document.getElementById("d_id6").src="/images/anB66.g ![]() ![]() } } } //上面是具体 ![]() ![]() ![]() ![]() function menushow(d_id){ switch(d_id){ ![]() history.dmenu=1; ![]() ![]() history.dmenu=2; ![]() ![]() history.dmenu=3; ![]() ![]() history.dmenu=4; ![]() ![]() history.dmenu=5; ![]() ![]() history.dmenu=6; ![]() } } //按下相关图片按钮后设置history.dmenu为相应 ![]() ![]() //--> </script> <table width="960" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="57" colspan="4"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="394" height="57" rowspan="2"><img src="/images/LOGO.g ![]() <td width="134" height="43"> </td> <td width="129" align="right" valign="middle"><avoid(0)" ![]() ![]() init2 ![]() } ![]() init ![]() //否则执行这个 } </script> 如此 ![]() ![]() ![]() ![]() ![]() ![]() ![]() 0
相关文章读者评论发表评论 |
|