带记录cookie功能图片切换特效

1个月前 (04-09 19:54)阅读36回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4714
  • 级别管理员
  • 主题942
  • 回复2
楼主

这个图片切换特效有一个很实用的功能,就是能记录cookie,每次刷新页面后都会继续上一次图片继续切换显示。

<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>带记录cookie功能图片切换特效_武鸣人</title>
<script language="JavaScript">
<!--
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));  }
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);  }
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; }
  return null;   }
//  assign expiration date variable for cookie
var expdate = new Date ();
FixCookieDate(expdate);
expdate.setTime(expdate.getTime() + (5 * 60 * 1000)) // 5 minutes
//  initialize countimg variable to track images
countimg = (GetCookie("countimg") != null) ? (GetCookie("countimg")-1) : -1
countimg = (countimg <-1) ? -1 : countimg
IMGArray = new Array(3)
if (document.images) {
IMGArray[0] = new Image(400,300)
IMGArray[1] = new Image(400,300)
IMGArray[2] = new Image(400,300)  }
//Old browsers get an array of empty strings
else {
IMGArray[0] = ""
IMGArray[1] = ""
IMGArray[2] = "" }
IMGArray[0].src = "/img/20240307_www_wuming_ren_53w_big.jpg"
IMGArray[0].URL = "https://www.wuming.ren"
IMGArray[1].src = "/img/20240307_www_wuming_ren_54w_big.jpg"
IMGArray[1].URL = "https://www.wuming.ren"
IMGArray[2].src = "/img/20240307_www_wuming_ren_55w_big.jpg"
IMGArray[2].URL = "https://www.wuming.ren"
function updateIM(countimg) { return countimg; }
//  functions for onMouseOver, onMouseOut, onClick event handlers
function wuming_ren_over() { updateIM(countimg)
if (IMGArray[countimg] != null ) {
window.status = IMGArray[countimg].URL; return true; }}
function wuming_ren_out() { window.status = ""; return true; }
function wuming_ren_click() { updateIM(countimg)
if (IMGArray[countimg] != null ) {
location = IMGArray[countimg].URL }}
//  Image swapping function
function showIMAGE() { updateIM(countimg++)
if (document.images) {
//Make sure countimg does'nt get too big
if ( countimg > IMGArray.length - 1 ) { countimg = IMGArray.length - IMGArray.length }
document.images.banner.src = IMGArray[countimg].src
exbannerID = setTimeout("showIMAGE()",2500) }}
function setIt2() { updateIM(countimg)
document.cookie = "countimg=" + countimg + "; expires=" + expdate.toGMTString()  }
//  get cookie countimg onblur, onload
function getIt2() {
countimg = (GetCookie("countimg") != null) ? (GetCookie("countimg")) : 0
updateIM(countimg)
if (exbannerID != null) { clearTimeout(exbannerID); showIMAGE() }}
function initCOOKIES() {
window.onunload = setIt2
window.onfocus = getIt2
window.onblur = setIt2 }
function initBANNER() {
showIMAGE()
cookieID = setTimeout("initCOOKIES()",1000) }
window.onload = initBANNER
// -->
</script>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
<a onClick="wuming_ren_click()" onMouseOver="wuming_ren_over();return true;" onMouseOut="wuming_ren_out();return true;"><img src="" name="banner" border="0" ></a>
</body>
</html>


0
0
收藏0
回帖

带记录cookie功能图片切换特效 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息