基于JS實現(xiàn)二維碼圖片固定在右下角某處并跟隨滾動條滾動
更新時間:2017年02月08日 10:20:20 作者:孫瑞
這篇文章主要介紹了基于JS實現(xiàn)二維碼圖片固定在右下角某處并跟隨滾動條滾動,代碼簡單易懂非常不錯,具有參考借鑒價值,需要的朋友可以參考下
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>二維碼圖片固定在右下角某處并跟隨滾動條滾動</title>
</head>
<body>
<div style="width:1000px; height:1000px;">二維碼圖片固定在右下角某處并跟隨滾動條滾動</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實現(xiàn)二維碼圖片固定在右下角某處并跟隨滾動條滾動,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
原生JS封裝_new函數(shù)實現(xiàn)new關(guān)鍵字的功能
這篇文章主要介紹了原生JS封裝_new函數(shù),實現(xiàn)new關(guān)鍵字的功能 ,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2018-08-08
javascript實現(xiàn)unicode與ASCII相互轉(zhuǎn)換的方法
這篇文章主要介紹了javascript實現(xiàn)unicode與ASCII相互轉(zhuǎn)換的方法,涉及JavaScript字符串的遍歷、正則匹配及編碼轉(zhuǎn)換相關(guān)技巧,需要的朋友可以參考下2015-12-12

