当前位置: 首页 > news >正文

网页视口内广告浮动弹窗

1 <div id="img1" style="top: 21px; left: 491px;"> 
2  <!--链接地址--><a href="#" target="_blank"> 
3  <!--图片地址--><img src="/uploadfiles/image/logo.png" border="0"> 
4  </a> 
5 </div>

 

 1 <script type="text/javascript">
 2  var xPos = 300; //起始定位:X轴位置(居左像素) 
 3  var yPos = 200;  //起始定位:Y轴位置(居上像素) 
 4  var step = 1; //每次移动像素 
 5  var delay = 10; //每移1次setp所需时间(单位毫秒,1000毫秒=1秒) 
 6  var height = 0; 
 7  var Hoffset = 0; 
 8  var Woffset = 0; 
 9  var yon = 0; 
10  var xon = 0; 
11  var pause = true; 
12  var interval; 
13  var obj=window.document.getElementById("img1"); //获取DIV图层对象 
14  obj.style.top = yPos + "px"; 
15  function changePos(){ 
16      width = window.innerWidth == 0 ? (document.documentElement.clientWidth == 0 ? document.body.clientWidth : document.documentElement.clientWidth) : window.innerWidth; 
17      height = window.innerHeight == 0 ? (document.documentElement.clientHeight == 0 ? document.body.clientHeight : document.documentElement.clientHeight) : window.innerHeight; 
18      Woffset = obj.offsetWidth; Hoffset = obj.offsetHeight; scrollLeft = document.documentElement.scrollLeft == 0 ? document.body.scrollLeft : document.documentElement.scrollLeft; 
19      scrollTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop : document.documentElement.scrollTop; 
20      obj.style.left = xPos + scrollLeft + "px"; 
21      obj.style.top = yPos + scrollTop + "px"; 
22      if (yon) {yPos = yPos + step;} else {yPos = yPos - step;} 
23      if (yPos < 0) {yon = 1;yPos = 0;} 
24      if (yPos >= (height - Hoffset)) {yon = 0;yPos = (height - Hoffset);} 
25      if (xon) {xPos = xPos + step;} else {xPos = xPos - step;} 
26      if (xPos < 0) {xon = 1;xPos = 0;} 
27      if (xPos >= (width - Woffset)) {xon = 0;xPos = (width - Woffset);} 
28  } 
29  function start(){ obj.visibility = "visible"; interval = setInterval('changePos()', delay); } 
30  function pause_resume(){ if(pause){ clearInterval(interval); pause = false; }else{ interval = setInterval('changePos()',delay); pause = true;  } } 
31  start(); 
32 </script>

 

 

转载于:https://www.cnblogs.com/ghfjj/p/6306356.html

相关文章:

  • 使用DHCP snooping 功能防止DHCP Server仿冒者***(华为交换机)
  • windows下通过Chocolatey安装或升级node.js
  • Python 调用系统命令
  • Linux编程学习笔记 | Linux IO学习[1] - 文件IO
  • Java double字符串转数字
  • PHP中的 !== 与 !=
  • 线程生命周期状态UML图
  • 【JAVA秒会技术之异常解决】解决Eclipse添加新server时无法选择Tomcat7的问题
  • Leopard概述
  • Spring源码阅读-ApplicationContext
  • linux系统下查看网卡的UUID
  • String类型的方法总结
  • 通过Servlet生成验证码图片(转)
  • C#实现MD5字符串加密
  • 集成软件开发工具有多难?现实很残酷!
  • ----------
  • [译] 怎样写一个基础的编译器
  • [译]前端离线指南(上)
  • HashMap ConcurrentHashMap
  • Java 网络编程(2):UDP 的使用
  • Netty源码解析1-Buffer
  • Redux 中间件分析
  • 服务器从安装到部署全过程(二)
  • 构造函数(constructor)与原型链(prototype)关系
  • 码农张的Bug人生 - 初来乍到
  • 前端 CSS : 5# 纯 CSS 实现24小时超市
  • 前端自动化解决方案
  • 通过来模仿稀土掘金个人页面的布局来学习使用CoordinatorLayout
  • 为什么要用IPython/Jupyter?
  • 用简单代码看卷积组块发展
  • 走向全栈之MongoDB的使用
  • linux 淘宝开源监控工具tsar
  • 阿里云服务器购买完整流程
  • 长三角G60科创走廊智能驾驶产业联盟揭牌成立,近80家企业助力智能驾驶行业发展 ...
  • #100天计划# 2013年9月29日
  • (day 2)JavaScript学习笔记(基础之变量、常量和注释)
  • (delphi11最新学习资料) Object Pascal 学习笔记---第8章第2节(共同的基类)
  • (读书笔记)Javascript高级程序设计---ECMAScript基础
  • (附源码)ssm高校升本考试管理系统 毕业设计 201631
  • (十一)JAVA springboot ssm b2b2c多用户商城系统源码:服务网关Zuul高级篇
  • ***linux下安装xampp,XAMPP目录结构(阿里云安装xampp)
  • *p++,*(p++),*++p,(*p)++区别?
  • .NET / MSBuild 扩展编译时什么时候用 BeforeTargets / AfterTargets 什么时候用 DependsOnTargets?
  • .net php 通信,flash与asp/php/asp.net通信的方法
  • .NET6实现破解Modbus poll点表配置文件
  • .NET企业级应用架构设计系列之技术选型
  • @RequestParam详解
  • [ 数据结构 - C++] AVL树原理及实现
  • [20170728]oracle保留字.txt
  • [BZOJ1089][SCOI2003]严格n元树(递推+高精度)
  • [C\C++]读入优化【技巧】
  • [C++]priority_queue的介绍及模拟实现
  • [docker] Docker容器服务更新与发现之consul
  • [hdu1561] The more, The Better 【树形DP】
  • [IE编程] IE8的SDK 下载