首页 > 语言 > JavaScript > 正文

JavaScript实现点击文字切换登录窗口的方法

2024-05-06 16:19:54
字体:大 中 小
来源:转载
供稿:网友

这篇文章主要介绍了JavaScript实现点击文字切换登录窗口的方法,涉及javascript操作div层及相关样式的技巧,需要的朋友可以参考下

本文实例讲述了JavaScript实现点击文字切换登录窗口的方法。分享给大家供大家参考。具体分析如下:

这是一款动画切换层窗口的特效,点击不同的登录用户会切换到不同的登录窗口,窗口内的内容可以是不一样的,是比较实用的一款代码。

 

 
  1. <html> 
  2. <head> 
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  4. <title>JAVASCRIPT适时切换登录窗口</title> 
  5. <style> 
  6. TD{ 
  7. font-size: 9pt; color: #66DDDD} 
  8. .out{ 
  9. font-size: 9pt; color: #66DDDD;border-width:1px; 
  10. border-style:solid;border-color:0090c0 0070b0 0070b0 0090c0; 
  11. cursor:hand; background:0080c0; text-align: center 
  12. } 
  13. .out2 { 
  14. text-align: center} 
  15. .in,.out2{ 
  16. font-size: 9pt; color: #66DDDD;border-width:1px; 
  17. border-style:solid;border-color:0070b0 0090c0 0090c0 0070b0; 
  18. background:0078b8;cursor:default 
  19. } 
  20. </style> 
  21. </head> 
  22. <body> 
  23. <script> 
  24. var temp_num = null; 
  25. var now_num = null; 
  26. var the_top = 130;  
  27. var the_bottom = 150  
  28. var no_can_do = false; 
  29. function Show_menu(u_num,d_num) 
  30. { 
  31. event.srcElement.className = "out2"; 
  32. if(no_can_do) 
  33. { 
  34. return; 
  35. }  
  36. now_num = d_num; 
  37. if(temp_num)  
  38. { 
  39. if(document.getElementById("menu_"+temp_num).doing) 
  40. { 
  41. clearInterval(document.getElementById("menu_"+temp_num).doing); 
  42. } 
  43. } 
  44. else 
  45. { 
  46. temp_num = u_num; 
  47. } 
  48. document.getElementById("menu_"+temp_num).doing = setInterval("set_menu()",10); 
  49. } 
  50. function set_menu() 
  51. { 
  52. no_can_do = true; 
  53. document.getElementById("form_"+temp_num).style.display = "none"; 
  54. var if_move = document.getElementById("div_"+temp_num).style.pixelHeight - 6; 
  55. if(if_move>1) 
  56. { 
  57. document.getElementById("div_"+temp_num).style.pixelHeight = if_move; 
  58. } 
  59. else 
  60. { 
  61. document.getElementById("div_"+temp_num).style.pixelHeight = 1; 
  62. var if_stop = document.getElementById("menu_"+temp_num).style.pixelTop - 1; 
  63. if(if_stop>the_top) 
  64. { 
  65. document.getElementById("menu_"+temp_num).style.pixelTop = if_stop; 
  66. document.getElementById("menu_"+now_num).style.pixelTop += 1; 
  67. } 
  68. else 
  69. { 
  70. document.getElementById("menu_"+temp_num).style.pixelTop = the_top; 
  71. document.getElementById("menu_"+now_num).style.pixelTop = the_bottom; 
  72. var if_end = document.getElementById("div_"+now_num).style.pixelHeight + 6; 
  73. if(if_end < 182) 
  74. { 
  75. document.getElementById("div_"+now_num).style.pixelHeight = if_end 
  76. } 
  77. else 
  78. { 
  79. document.getElementById("div_"+now_num).style.pixelHeight = 182; 
  80. clearInterval(document.getElementById("menu_"+temp_num).doing); 
  81. document.getElementById("menu_"+temp_num).doing = false; 
  82. document.getElementById("form_"+now_num).style.display = "block"; 
  83. temp_num = null; 
  84. no_can_do = false; 
  85. } 
  86. } 
  87. } 
  88. } 
  89. function returnIT() 
  90. { 
  91. event.srcElement.className = "out"; 
  92. } 
  93. </script> 
  94. <div id="menu_0" style="position: absolute; top: 127; left: 176; width: 340; height: 201"> 
  95.  
  96. <table border="0" width="100%" style="background-color: #0080C0" cellspacing="0" cellpadding="0" height="19"> 
  97. <tr> 
  98. <td width="277" class="out" height="19" style="cursor: default"> </td> 
  99. <td width="58" class="out" height="19" onmousedown="Show_menu(1,0)" onmouseup="returnIT()">管理员</td> 
  100. </tr> 
  101. </table> 
  102. <div id="div_0" style="position: relative; width: 339; height: 1; overflow: hidden"> 
  103. <table border="0" width="100%" style="background-color: #0080C0" cellspacing="0" cellpadding="0" height="182"> 
  104. <tr> 
  105. <td width="100%" height="182"> 
  106. <form id="form_0" style="position: relative; left:70; top:10;font-family: Arial; display: none" 
  107. action="javascript:;" method="post" align="center"> 
  108. 超级管理员: 
  109. <br> 
  110. <br> 
  111. 帐号: <input class="in" style="WIDTH: 100px" size="20"> mail.cn<br>  
  112. 密码: <input class="in" type="password" size="20"><br> 
  113. <br>  
  114. <input class="out" onfocus="this.blur()" type="button" value="登录">  
  115. </form> 
  116.  </td> 
  117. </tr> 
  118. </table> 
  119. </div> 
  120. </div> 
  121. <div id="menu_1" style="position: absolute; top: 146; left: 176; width: 339; height: 219"> 
  122. <table border="0" width="100%" style="background-color: #0080C0" cellspacing="0" cellpadding="0" height="19"> 
  123. <tr> 
  124. <td width="277" class="out" height="19" style="cursor: default"> </td> 
  125. <td width="58" class="out" height="19" onmousedown="Show_menu(0,1)" onmouseup="returnIT()">一般用户</td> 
  126. </tr> 
  127. </table> 
  128. <div id="div_1" style="position: relative; width: 339; height: 182; overflow: hidden"> 
  129. <table border="0" width="100%" style="background-color: #0080C0" cellspacing="0" cellpadding="0" height="100%"> 
  130. <tr> 
  131. <td width="100%" height="182"> 
  132. <form id="form_1" style="position: relative; left:70; top:10;font-family: Arial; display: block" action="javascript:;" 
  133. method="post" align="center"> 
  134. 一般用户: 
  135. <br> 
  136. <br> 
  137. 帐号: <input class="in" style="WIDTH: 100px" size="20"> mail.cn<br>  
  138. 口令: <input class="in" type="password" size="20"><br> 
  139. <br> 
  140. <input class="out" onfocus="this.blur()" type="button" value="登录">  
  141. </form> 
  142.  </td> 
  143. </tr> 
  144. </table> 
  145. </div> 
  146. </div> 
  147. </body> 
  148. </html> 

希望本文所述对大家的javascript程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选