ITPub博客

首页 > IT职业 > IT图书 > 利用Cookis制作的导航效果

利用Cookis制作的导航效果

原创 IT图书 作者:chunzhisu 时间:2014-08-19 10:22:14 0 删除 编辑
  • 利用Cookis制作的导航效果,链接在图片上面,鼠标移上去后会看到链接,当你点击一次的时候,就能记得,下次就直接进入这个站了。


点击(此处)折叠或打开

  1. <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>石家庄水泵厂</TITLE>
  5. </HEAD>
  6. <BODY>
  7. <script languague=\"javascript1.2\">
  8. <!--
  9. function setCookie(value, expires, domain) {
  10.   var curCookie = \"home=\" + escape(value) + \"; expires=\" + expires.toGMTString() + \"; domain=\" + domain;
  11.   document.cookie = curCookie;
  12. }

  13. function getCookie(Name) {
  14.         var search = Name + \"=\";
  15.         if (document.cookie.length > 0) {
  16.                 // if there are any cookies
  17.                 offset = document.cookie.indexOf(search);
  18.                 if (offset != -1) {
  19.                         // if cookie exists
  20.                         offset += search.length;
  21.                         // set index of beginning of value
  22.                         end = document.cookie.indexOf(\";\", offset);
  23.                         // set index of end of cookie value
  24.                         if (end == -1)
  25.                                 end = document.cookie.length;
  26.                         return unescape(document.cookie.substring(offset, end));
  27.                 }
  28.         }
  29. }

  30. function setHome(myhome){
  31.         var today = new Date();
  32.         var expires = new Date();
  33.         var domainName = \"tom.com\";
  34.         expires.setTime(today.getTime() + 1000*60*60*24*365);
  35.         if (document.homeform.setgo.checked){
  36.                 setCookie(myhome,expires,domainName);
  37.         }
  38.         switch (myhome){
  39.                 case \"cn\":
  40.                         document.location = \"http://cn.tom.com/\";
  41.                         break;
  42.                 case \"sh\":
  43.                         document.location = \"http://sh.tom.com/\";
  44.                         break;
  45.                 case \"gz\":
  46.                         document.location = \"http://gz.tom.com/\";
  47.                         break;
  48.                 case \"hk\":
  49.                         document.location = \"http://hk.tom.com/\";
  50.                         break;
  51.                 case \"eng\":
  52.                         document.location = \"http://us.tom.com/\";
  53.                         break;
  54.         }

  55. }

  56. var pHome = getCookie(\"home\");
  57. if (pHome){
  58.         switch (pHome){
  59.                 case \"cn\":
  60.                         document.location = \"/\";
  61.                         break;
  62.                 case \"sh\":
  63.                         document.location = \"http://www.baidu.com/\";
  64.                         break;
  65.                 case \"gz\":
  66.                         document.location = \"http://www.csdn.net/\";
  67.                         break;
  68.                 case \"hk\":
  69.                         document.location = \"http://www.qq.com/\";
  70.                         break;
  71.                 case \"eng\":
  72.                         document.location = \"http://www.sina.com/\";
  73.                         break;
  74.         }
  75. }
  76. //-->
  77. </script>
  78. <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"98%\">
  79.   <tr align=\"center\">
  80.     <td>
  81.       <table width=\"480\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  82.                <tr valign=\"top\" align=\"center\">
  83.           <td height=\"145\"><img src=\"/jscss/demoimg/wall_s3.jpg\" width=\"480\" height=\"145\" usemap=\"#Map\" border=\"0\"><map name=\"Map\"><area shape=\"rect\" coords=\"351,37,468,78\" href=\"javascript:setHome(\'hk\')\"><area shape=\"rect\" coords=\"9,37,100,78\" href=\"javascript:setHome(\'cn\')\"><area shape=\"rect\" coords=\"107,37,213,78\" href=\"javascript:setHome(\'sh\')\"><area shape=\"rect\" coords=\"222,37,344,78\" href=\"javascript:setHome(\'gz\')\"><area shape=\"rect\" coords=\"141,91,314,116\" href=\"javascript:setHome(\'eng\')\"></map></td>
  84.         </tr>
  85.       </table>
  86.     </td>
  87.   </tr>
  88.    <tr align=\"center\">
  89.     <td>
  90.       <table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  91.         <tr>
  92.           <td valign=\"top\">
  93.             <form name=\"homeform\" method=\"post\">
  94.               <input type=\"checkbox\" name=\"setgo\" value=\"1\">下次直接进入这个分站...
  95.             </form>
  96.           </td>
  97.          </tr>
  98.       </table>
  99.     </td>
  100.   </tr>
  101. </table>
  102. </BODY>
  103. </HTML>


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29737856/viewspace-1253674/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-07-04

  • 博文量
    95
  • 访问量
    122208