基于JS實(shí)現(xiàn)二維碼圖片固定在右下角某處并跟隨滾動(dòng)條滾動(dòng)
1、準(zhǔn)備一張二維碼圖片,大小、圖片自己定義我這里用的寬度和高度都是253,名稱weixin.jpg
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>二維碼圖片固定在右下角某處并跟隨滾動(dòng)條滾動(dòng)</title>
</head>
<body>
<div style="width:1000px; height:1000px;">二維碼圖片固定在右下角某處并跟隨滾動(dòng)條滾動(dòng)</div>
<script language="javascript">
function wx_scroll(){
var topH=-80;
var leftW=10;
var sHeight,sWidth,cHeight;
//alert(document.documentElement.clientWidth);
(document.body.scrollLeft==0)?sWidth=document.documentElement.scrollLeft + document.documentElement.clientWidth - 260 :sWidth=document.body.scrollLeft+ document.documentElement.clientWidth - 260 ;
(document.body.scrollTop==0)?sHeight=document.documentElement.scrollTop+ document.documentElement.clientHeight - 260 :sHeight=document.body.scrollTop+ document.documentElement.clientHeight - 260;
document.getElementById("bar_float").style.left=eval(sWidth+leftW) +"px";
document.getElementById("bar_float").style.top=eval(sHeight+topH) +"px";
}
setInterval("wx_scroll()",100);
</script>
<div id="bar_float" style="position: absolute; display:block; z-index: 10000; left: 1216px; top: -80px;">
<div id="stayTopleft">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td colspan="2" valign="top"><img src="weixin.jpg" width="253" height="253" border="0"></td>
</tr>
<tr>
</table></div>
</div>
</body>
</html>
以上所述是小編給大家介紹的基于JS實(shí)現(xiàn)二維碼圖片固定在右下角某處并跟隨滾動(dòng)條滾動(dòng),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
JS實(shí)現(xiàn)靜止元素自動(dòng)移動(dòng)示例
這篇文章主要介紹了JS實(shí)現(xiàn)靜止元素自動(dòng)移動(dòng)的具體實(shí)現(xiàn),需要的朋友可以參考下2014-04-04
原生JS封裝_new函數(shù)實(shí)現(xiàn)new關(guān)鍵字的功能
這篇文章主要介紹了原生JS封裝_new函數(shù),實(shí)現(xiàn)new關(guān)鍵字的功能 ,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-08-08
javascript實(shí)現(xiàn)unicode與ASCII相互轉(zhuǎn)換的方法
這篇文章主要介紹了javascript實(shí)現(xiàn)unicode與ASCII相互轉(zhuǎn)換的方法,涉及JavaScript字符串的遍歷、正則匹配及編碼轉(zhuǎn)換相關(guān)技巧,需要的朋友可以參考下2015-12-12
Javascript柯里化實(shí)現(xiàn)原理及作用解析
這篇文章主要介紹了Javascript柯里化實(shí)現(xiàn)原理及作用解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-10-10
使用Web?Component實(shí)現(xiàn)防篡改水印
Web?Component內(nèi)部有鉤子天然支持被篡改時(shí)被觸發(fā),用來(lái)防篡改非常方便,所以本文就將使用Web?Component實(shí)現(xiàn)防篡改水印,感興趣的小伙伴可以了解下2023-12-12
javascript 函數(shù)參數(shù)限制說(shuō)明
我依稀記得哪本書(shū)上有說(shuō)過(guò),實(shí)參數(shù)限制是32個(gè)? 現(xiàn)在想想估計(jì)是我記錯(cuò)了..他也許說(shuō)的是32位.2010-11-11

