ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (±Ð¾Ç²Ä29½g) Cookies À³¥Î_ÂsÄýªÌªº»y¨¥ª©¥»

[±Ð¾Ç] (±Ð¾Ç²Ä29½g) Cookies À³¥Î_ÂsÄýªÌªº»y¨¥ª©¥»

¡uºô¸ôµL°ê¬É¡A¥@¬É¬O¤@®a¡v¡A§A¥H¬°ºô¸ô¤Wªº¸ê°T¦³°ê§O©Î¦a°ìªº°Ï¤À¶Ü¡H·íµM¨S¦³¡I¥@¬É¦U°ê¨Ï¥Î¦UºØ»y¨¥ªººô¤Í³£¦³¥i¯à¥úÁ{§Aªººô¯¸¡A¥H¤p»xªººô¯¸¨Ó»¡¡A¦³¨Ó¦Û¥xÆW¡B­»´ä¡B¤¤°ê¤j³°¡B¬Æ¦Ü¥[®³¤jªººô¤Í¨Ó°ÑÆ[¡A¦]¦¹¡A¬°ªA°È¥@¬É¦U°ê¨Ï¥Î¦UºØ»y¨¥ªººô¤Í¡A§A¥i¯à±Nºô¯¸³W¹º¦¨¦³¦h°ê»y¨¥ªºª©¥»¡A·íºô¤Í¨Ó°ÑÆ[®É¡A¥i¦Û¥Ñ¿ï¾Ü¥L¾A¦Xªº»y¨¥ª©¥»¨ÓÂsÄý¡C


·í¥@¬É¦U°ê¨Ï¥Î¦UºØ»y¨¥ªººô¤Í¨C¦¸¨Ó¨ì§Aªººô¯¸¡A¦pªGºô¤Í²Ä¤@¦¸¥úÁ{ºô¯¸½Ð¤H®a¿ï¾Ü¾A·íªº»y¨¥ª©¥»¨ÓÂsÄý¡A³o¬OµL¥i«p«Dªº¡A¦ýºô¤Í­Y¬O¦A«×¥úÁ{¡A§A¤S­n¤H®a¿ï¾Ü¤@¦¸»y¨¥ª©¥»¨ÓÂsÄý¡A³o¤Ó³Â·Ð¤F¡A¦n¹³¤£¬O«Ü¦nªº«Ý«È¤§¹D¡A©Ò¥H¡A§Ú­Ì¥i¥H§Q¥ÎCookies¨Ó°µ°O¿ý£«¡A·íºô¤Í²Ä¤@¦¸¥úÁ{®É¡A½Ð¥L¿ï¾Ü¾A·íªº»y¨¥ª©¥»¨ÓÂsÄý¡A¦p¤W¹Ï¡A¦Ó¥L¦A«×¥úÁ{§Ú­Ìºô¯¸®É¡A¤£»Ý­n¦A¿ï¾Ü¤@¦¸»y¨¥ª©¥»¡A§Ú­Ì·|ª½±µÂà¦Vºô­¶¨ì¾A¦X¥¦ªº»y¤åª©¥»¥h¡C


¦b¥»½d¨Òµ{¦¡¤¤¡A§Ú­Ì¥u»Ý­n¤@­ÓCookies¡A¥¦ªº¦WºÙ¬O¡G¡uLanguagename¡v¡A¥¦¬O¥Î¨Ó°O¿ýÂsÄýªÌªº»y¨¥ª©¥»¡A¨ä­È¦³¤U¦C¤TºØ¥i¯à¡G

  • big5¡G´¿¸g¨Ó°ÑÆ[¹Lºô¯¸¡A¦Ó¥B¡A©Ò¿ï¾Üªº»y¨¥ª©¥»¬°¤¤¤åÁcÅé¡C
  • GB¡G´¿¸g¨Ó°ÑÆ[¹Lºô¯¸¡A¦Ó¥B¡A©Ò¿ï¾Üªº»y¨¥ª©¥»¬°¤¤¤å²Åé¡C
  • null¡G¥H«e¨S¨Ó¹L¡A¬O²Ä¤@¦¸¨Ó³X¡A¥²¶·¿ï¾Ü»y¨¥ª©¥»¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¨­¥÷§PÂ_ªº¨ç¦¡
·í³X«È¶i¤J§Aªº­º­¶¡A§Ú­Ì²Ä¤@¥ó­n°µªº¨Æ¬O¥ý¥h½T»{Cookies¡ulanguagename¡vªº­È¡A¦pªGCookies¡ulanguagename¡v¦s¦b¡A«h¥Nªí³X«È´¿¸g¨Ó¹L¡A±µµÛ¤~¶}©l§PÂ_Cookies¡ulanguagename¡vªº­È¡A¦pªG¨ä­È¬°¡ubig5¡v¡A¥Nªí³X«È­nÂsÄýªº¬O¡y¤¤¤åÁcÅé¡zª©¥»ªººô­¶¡A§Ú­Ì´Nª½±µ±NÂsÄý¦ì¸mÂà¦V¨ì¡y¤¤¤åÁcÅé¡zª©¥»ªººô­¶¥h¡F¦Ó¨ä­È­Y¬O¡ugb¡v¡A¥Nªí³X«È­nÂsÄýªº¬O¡y¤¤¤å²Åé¡zª©¥»ªººô­¶¡A´N±NÂsÄý¦ì¸mÂà¦V¨ì¡y¤¤¤å²Åé¡zª©¥»ªººô­¶¥h¡A§Ú­Ì§â³o­Ó¨­¥÷§PÂ_ªº¨ç¦¡©R¦W¬°¡uchecklanguage()¡v¡G

checklanguage¨ç¦¡[¨­¥÷§PÂ_]
  1. function checklanguage()
  2. {
  3. if (getlanguage("languagename")=="big5")
  4. {
  5. window.location="big5.htm"
  6. }
  7. else if (getlanguage("languagename")=="gb")
  8. {
  9. window.location="gb.htm"
  10. }
  11. }
½Æ»s¥N½X
¦bµ{¦¡½X²Ä5»P²Ä9¦æ¤¤¡A§Ú­Ì©I¥sgetlanguage()¨ç¦¡¥hÀ°§Ú­Ì§â»y¨¥ª©¥»Cookies¡ulanguagename¡vªº­È¨ú¦^¨Ó¤ñ¸û¡A¦pªGgetlanguage()¨ç¦¡¦^¶Çªº­È¬O¡ubig5¡v¡A´Nª½±µ±NÂsÄý¦ì¸mÂà¦V¨ì¡y¤¤¤åÁcÅé¡zª©¥»ªººô­¶¥h¡F­Y¬O¡ugb¡v¡A´Nª½±µ±NÂsÄý¦ì¸mÂà¦V¨ì¡y¤¤¤å²Åé¡zª©¥»ªººô­¶¥h¡C£«¦pªGgetlanguage()¨ç¦¡¦^¶Çªº­È¤£¬O¡ubig5¡v©Î¡ugb¡v«ç»ò¿ì¡H¨º´N¤£°µ¥ô¦ó°Ê§@¡Aµ¥«ÝÂsÄýªÌ¿ï¾Ü¾A·íªºª©¥»¡C

¨­¥÷§PÂ_ªº¨ç¦¡checklanguage()­n¦bºô­¶¤U¸ü®É´N¤©¥H©I¥s¡A¥H«K¶}©l¶i¦æ¨­¥÷§PÂ_ªº°Ê§@¡G
  1. <body background="bg.gif" onLoad="checklanguage()">
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

Â^¨ú»y¨¥ª©¥»ªºCookies
Cookies¡ulanguagename¡vªº­ÈÃö«YµÛ¾ãÅ骺ÅܤơA·í¨­¥÷§PÂ_¨ç¦¡¡uchecklanguage()¡v­n¶i¦æ§PÂ_®É¡A´N­n¶i¦æCookies¡ulanguagename¡vªº¨ú­È°Ê§@¡A¦Ó³o­ÓÂ^¨úCookies­Èªº¤u§@´N¥æ¥ÑÂ^¨ú¨ç¦¡¡ugetlanguage()¡v¨Ó­t³d¡G

getlanguage¨ç¦¡[Â^¨úCookiesªº­È]
  1. function getlanguage(name)
  2. {
  3. name = name + "="
  4. if (document.cookie.length > 0)
  5. {
  6. position = document.cookie.indexOf(name)
  7. if (position != -1)
  8. {
  9. position = position + name.length
  10. endposition = document.cookie.indexOf(";" , position)
  11. if (endposition == -1)
  12. {
  13. endposition = document.cookie.length
  14. }
  15. return unescape(document.cookie.substring(position,endposition))
  16. }
  17. }
  18. return null
  19. }
½Æ»s¥N½X
¨Ï¥Îgetlanguage()¨ç¦¡¨ÓÂ^¨úCookiesªº­È¡A°È¥²µ¹¤©¨ç¦¡¤@­ÓCookiesªº¦WºÙ¡A³o¼Ë¨ç¦¡¤~ª¾¹D¬O­nÂ^¨ú¨º¤@­ÓCookiesªº­È¡I
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

³]©w»y¨¥ª©¥»ªºCookies
  ·íºô¤Í²Ä¤@¦¸¥úÁ{®É¡A§Ú­Ì·|½Ð¥L¶i¦æ»y¨¥ª©¥»ªº³]©w¡A¦bºô­¶¤¤§Ú­Ì©ñ¸m¤F¨â­Ó»y¨¥ª©¥»ªº¿ï¾Ü¹Ï¤ù¡A¨Ã¥B¬°¹Ï¤ù¥[¤W¤F¶WÃìµ²¡A³o­Ó¶WÃìµ²¥i¤£¬O­n³s¸Ñ¨ì¨ä¥Lºô­¶Ëç¡I¦bÃìµ²¼ÐÅÒ¤¤¬O¨Ï¥ÎJavaScriptªºµêÀÀ¨ó©w¡A¥¦·|¥h©I¥s§Ú­Ìªºsetlanguage()¨ç¦¡¡Asetlanguage()¨ç¦¡±NÂsÄýªÌ©Ò¿ï¾Üªº»y¨¥ª©¥»³]©w­ÈÀx¦s¨ì¦W¬°¡ulanguagename¡vªºCookies¸Ì¡G
  1. <p align="center">
  2. <a href="javascript:setlanguage('big5')">
  3. <img border="0" src="big5.gif"></a></p>
  4. <p align="center">
  5. <a href="javascript:setlanguage('gb')">
  6. <img border="0" src="gb.gif"></a></p>
½Æ»s¥N½X


¨Ï¥Îsetlanguage()¨ç¦¡¨ÓÀx¦sCookiesªº­È¡A¥²¶·µ¹¤©¨ç¦¡¤@­ÓCookiesªº¡y­È¡z¡I

setlanguage¨ç¦¡[Àx¦sCookiesªº­È]
  1. function setlanguage(language)
  2. {
  3. begindate = new Date()
  4. enddate =new Date()
  5. enddate.setDate( begindate.getDate() + 365 )

  6. document.cookie="languagename=" + escape(language) + "; expires=" + enddate.toGMTString()

  7. if (language=="big5")
  8. {
  9. window.location="big5.htm"
  10. }
  11. else if (language=="gb")
  12. {
  13. window.location="gb.htm"
  14. }
  15. }
½Æ»s¥N½X
setlanguage()¨ç¦¡ªº¤º®e¤À¬°¨â­Ó³¡¤À¡A²Ä¤@­Ó³¡¤À¬°µ{¦¡½X²Ä3¦Ü7¦æ¡A³o¬qµ{¦¡±Ô­z¬O¥Î¨Ó¼g¤JCookiesªº­È¡A¥H¤Î³]©wCookiesªº¨ì´Á¤é¡F²Ä¤G­Ó³¡¤À¬°µ{¦¡½X²Ä9¦Ü16¦æ¡A¥Î¨Ó¶i¦æºô­¶ª©¥»ªºÂà¦V¡C

test.htm [»y¨¥ª©¥»§PÂ_»P³]©w]
  1. <html>

  2. <head>
  3. <meta http-equiv="Content-Language" content="zh-tw">
  4. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  5. <title>ºô­¶ª©¥»Àˬd</title>
  6. </head>

  7. <SCRIPT Language="JavaScript">
  8. //¨ú±o»y¨¥ª©¥»ªºcookies­ÈÂ^¨ú¨ç¦¡
  9. function getlanguage(name)
  10. {
  11. name = name + "="
  12. if (document.cookie.length > 0)
  13. {
  14. position = document.cookie.indexOf(name)
  15. if (position != -1)
  16. {
  17. position = position + name.length
  18. endposition = document.cookie.indexOf(";" , position)
  19. if (endposition == -1)
  20. {
  21. endposition = document.cookie.length
  22. }
  23. return unescape(document.cookie.substring(position,endposition))
  24. }
  25. }
  26. return null
  27. }

  28. //³]©w»y¨¥ª©¥»ªºcookies­È¨ç¦¡
  29. function setlanguage(language)
  30. {
  31. //«Ø¥ß¤é´Á®É¶¡ª«¥ó
  32. begindate = new Date()
  33. enddate =new Date()
  34. //³]©wCookies¨ì´Á¤é
  35. enddate.setDate( begindate.getDate() + 365 )
  36. //¼g¤JCookiesªº¸ê®Æ¤Î¨ì´Á¤é
  37. document.cookie="languagename=" + escape(language) + "; expires=" + enddate.toGMTString()

  38. //³]©w¦n»y¨¥ª©¥»«á,±Nºô­¶Âà¦V¦ÜÂsÄýªÌ¿ï¾Üªº»y¨¥ºô­¶¥h
  39. if (language=="big5")
  40. {
  41. window.location="big5.htm"
  42. }
  43. else if (language=="gb")
  44. {
  45. window.location="gb.htm"
  46. }
  47. }

  48. //Àˬd¬O§_¤w¨Ó¯¸°ÑÆ[¹L¨Ã³]©w¹L»y¨¥
  49. function checklanguage()
  50. {
  51. if (getlanguage("languagename")=="big5")
  52. {
  53. window.location="big5.htm"
  54. }
  55. else if (getlanguage("languagename")=="gb")
  56. {
  57. window.location="gb.htm"
  58. }
  59. }
  60. </SCRIPT>

  61. <!-- ºô­¶¸ü¤J®É¥ß§Y©I¥s¨­¥÷§PÂ_¨ç¦¡ -->
  62. <body background="bg.gif" onLoad="checklanguage()">
  63. <p align="center">
  64. <img border="0" src="twbtsb1.gif"></p>
  65. <p align="center">
  66. <img border="0" src="choose.gif"></p>
  67. <p align="center">
  68. <!-- ¤¤¤åÁcÅ骺Ãìµ² -->
  69. <a href="javascript:setlanguage('big5')">
  70. <img border="0" src="big5.gif"></a></p>
  71. <p align="center">
  72. <!-- ¤¤¤åÁcÅ骺Ãìµ² -->
  73. <a href="javascript:setlanguage('gb')">
  74. <img border="0" src="gb.gif"></a></p>
  75. </body>

  76. </html>
½Æ»s¥N½X
§¹¾ãÀ³¥Î½d¨ÒÀ£ÁYÀɤU¸ü: cookies.rar (31.75 KB)
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¤H¥Í³Ì¤jªº¦¨´N¬O±q¥¢±Ñ¤¤¯¸°_¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD