JS悬浮移动窗口(悬浮广告)的特效代码
,之后随时间使窗口位移, 2,页面加载完成之后向页面插入窗口,{id:removeMW}).css({width:20px,如下: !DOCTYPE htmlhtmlheadtitleJS悬浮移动窗口(悬浮广告)-/titlemeta http-equiv=Content-Type content=text/html; charset=UTF-8script type=text/javascript src=http://www.dismall.com/thread-957-1-1.html/a_10116//js/jquery-1.7.min.js/scriptscript$(function(){//写入div$(div/, 先来看用javascript的实现方法,鼠标离开继续运动,点击按钮关闭窗口。
button);oneButton.setAttribute(value,每当位移到游览器边缘时反向运动。
{id:moveWindow}).css({width:200px,之后向窗口插入关闭按钮,background:#663398, 以上代码仅限适当使用,height:200px,border:solid 3px #2F74A7,float:right}).appendTo(#moveWindow);//定时器var move = setInterval(moves。
100);}//删除oneButton.onclick=function(){document.body.removeChild(oneInner);}}/script/headbody/body/html 下面这个是jquery实现的悬浮广告代码,你懂,使用setInterval()函数触发moves()函数开始动画,建议慎用, 具体实现思路: 当页面加载完成之后向页面插入窗口,x);if (oneButton.style.cssFloat){oneButton.style.cssFloat=right}else{oneButton.style.styleFloat=right}oneInner.appendChild(oneButton);document.body.appendChild(oneInner);//定时器var a1a = setInterval(moves。
为不影响用户体验。
height:20px,100);});//点击按钮关闭$(#removeMW).click(function(){$(#moveWindow).remove();});})/script/headbody/body/html 思路分享: 1,添加其他事件:鼠标悬停停止运动,moves函数:首先获取当前窗口位置,100);//函数var x = 10;var y = 10;function moves(){var tops = oneInner.offsetTopvar lefts = oneInner.offsetLeftif (lefts=document.documentElement.clientWidth-oneInner.offsetWidth||lefts=0){x=-x}if (tops=document.documentElement.clientHeight-oneInner.offsetHeight||tops=0){y=-y}tops+=y;lefts+=x;oneInner.style.top=tops+pxoneInner.style.left=lefts+px}//悬停停止oneInner.onmouseover=function(){clearInterval(a1a);}//放手继续运动oneInner.onmouseout=function(){a1a =setInterval(moves。
left:lefts});}//悬停停止运动$(#moveWindow).mouseover(function(){clearInterval(move);});//移开鼠标后继续运动$(#moveWindow).mouseout(function(){move = setInterval(moves,background:#663398;position:absolute;width:100px;height:100px;border:solid 3px #2F74A7;cursor:pointer;);var oneButton = document.createElement(input);oneButton.setAttribute(type,position:absolute。
之后向窗口插入关闭按钮, 3,代码如下: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN htmlheadtitleJS悬浮移动窗口(悬浮广告)-/titlemeta name=Generator content=EditPlusmeta name=Author content=meta name=Keywords content=meta name=Description content=script type=text/javascriptwindow.onload=function(){//写入var oneInner = document.createElement(div);oneInner.setAttribute(style,cursor:pointer}).appendTo(body);//写入关闭按钮$(div/, 4,使用setInterval()函数触发moves()函数开始动画,100);var x= 10;var y= 10;function moves (){var mw = $(#moveWindow).offset();var lefts =mw.left;var tops = mw.top;if (lefts=$(window).width()-$(#moveWindow).width()||lefts=0){x=-x}if (tops=$(window).height()-$(#moveWindow).height()||tops=0){y=-y}lefts+=x;tops+=y;$(#moveWindow).offset({top:tops。
background:red,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jq/jc/9559.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
PHP识别相片是否是颠倒的
时间:2020-12-28
-
python编程有哪些ide
时间:2020-12-28
-
python开发工程师是做什么
时间:2020-12-28
-
php构造函数的作用
时间:2020-12-28
-
php怎么跟数据库连接
时间:2020-12-28
-
php实现顺序线性表
时间:2020-12-28
-
Python多重继承中的菱形继
时间:2020-12-28
-
php中break的作用
时间:2020-12-28
热门文章
-
php中常用的正则表达式使用方法
时间:2020-12-25
-
asp与php区别是什么?
时间:2020-12-27
-
PHP识别相片是否是颠倒的,并且重新摆正
时间:2020-12-28
-
Yii授权之基于角色的存取控制 (RBAC)
时间:2020-12-23
-
php的一键安装包有哪些 php环境搭建
时间:2020-12-19
-
php实现对图片对称加解密(适用身份证加
时间:2020-12-25
-
php如何理解面向对象
时间:2020-12-28
-
超详细分析php docker的原理及作用
时间:2020-12-27
-
Python控制Excel实现自动化办公
时间:2020-12-23
-
session的作用是什么
时间:2020-12-25
