// JavaScript Document function $id(o){return document.getElementById(o)} function jihe() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){ //对应 //================= //输出查询跳转Loading document.write(""); //滚动JS======================= document.write("
"); //左下角 document.write("
"); //右下角 document.write("
"); //对联上左 document.write("
"); //对联上右 //填充ad内容======================= document.write(""); $id('GoIfr').src="/awaphengfu/js/gg.php"; $id('GoIfr').style.display="none"; } } //列表和文章右侧悬浮 window.onload = function() { var ffRight = document.querySelector('.site_you');//site_you的父级DIV是site_zuoyou需要添加css样式position: relative; var menuCont = document.querySelector('.site_zuoyou'); var startPosition = menuCont.offsetTop; /* js内的函数fixed需要在css文件中添加这些动态CSS样式 .fixed { position: fixed; top: 0; // site_you样式将在JavaScript中以fixed动态设置 } .fixed-top { position: fixed; top: 0; } .fixed-bottom { position: absolute; bottom: 0; } */ // 在 site_you 转换为 fixed 之前,获取其相对于视口的左边界位置 var ffRightInitialLeft = ffRight.getBoundingClientRect().left; function onScroll() { var currentScroll = window.pageYOffset; var stopPosition = startPosition + menuCont.offsetHeight - ffRight.offsetHeight; // 停止的位置 if (currentScroll > startPosition && currentScroll < stopPosition) { // 滚动条超过ff_right顶部位置,并且还未到达停止位置 ffRight.style.position = 'fixed'; ffRight.style.top = '0'; ffRight.style.left = ffRightInitialLeft + 'px'; } else if (currentScroll >= stopPosition) { // 滚动条到达停止位置 ffRight.style.position = 'absolute'; ffRight.style.top = stopPosition - startPosition + 'px'; ffRight.style.left = ffRightInitialLeft - menuCont.getBoundingClientRect().left + 'px'; } else { // 滚动条在最初的ff_right位置或之上 ffRight.style.position = 'static'; } } window.addEventListener('scroll', onScroll); onScroll(); // 触发滚动事件以初始化位置 };