首页 > web前端 > html教程 > 怎么让下面代码弹出的图片定住?_html/css_WEB-ITnose

怎么让下面代码弹出的图片定住?_html/css_WEB-ITnose

WBOY
发布: 2016-06-24 12:12:07
原创
1350 人浏览过

// 右下角弹出图片
document.writeln("")
document.writeln("

 ");
document.writeln("怎么让下面代码弹出的图片定住?_html/css_WEB-ITnose"); 
document.writeln("
");
var bodyfrm = ( document.compatMode.toLowerCase()=="css1compat" ) ? document.documentElement : document.body;
var adst = document.getElementById("qqaddiv").style;
adst.top = ( bodyfrm.clientHeight - 172) + "px";
adst.left = ( bodyfrm.clientWidth - 252 ) + "px";
function moveR() {
 adst.top = ( bodyfrm.scrollTop + bodyfrm.clientHeight - 172 ) + "px";
 adst.left = ( bodyfrm.scrollLeft + bodyfrm.clientWidth - 252 ) + "px";
}
setInterval("moveR();", 80);


怎么让这个在右下角弹出的图片定住不变,意思就是不管怎么拉动下拉框这个图片都不会动!


回复讨论(解决方案)

你可以参考

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">





<script> <br /> //以下所有脚本只为IE6写,其他浏览器完全可以删除。 <br /> function getViewportScrollX() { <br /> var scrollX = 0; <br /> if (document.documentElement && document.documentElement.scrollLeft) { <br /> scrollX = document.documentElement.scrollLeft; <br /> } <br /> else if (document.body && document.body.scrollLeft) { <br /> scrollX = document.body.scrollLeft; <br /> } <br /> else if (window.pageXOffset) { <br /> scrollX = window.pageXOffset; <br /> } <br /> else if (window.scrollX) { <br /> scrollX = window.scrollX; <br /> } <br /> return scrollX; <br /> } <br /> <br /> function getViewportScrollY() { <br /> var scrollY = 0; <br /> if (document.documentElement && document.documentElement.scrollTop) { <br /> scrollY = document.documentElement.scrollTop; <br /> } <br /> else if (document.body && document.body.scrollTop) { <br /> scrollY = document.body.scrollTop; <br /> } <br /> else if (window.pageYOffset) { <br /> scrollY = window.pageYOffset; <br /> } <br /> else if (window.scrollY) { <br /> scrollY = window.scrollY; <br /> } <br /> return scrollY; <br /> } <br /> <br /> function getViewportWidth() { <br /> var width = 0; <br /> if (document.documentElement && document.documentElement.clientWidth) { <br /> width = document.documentElement.clientWidth; <br /> } <br /> else if (document.body && document.body.clientWidth) { <br /> width = document.body.clientWidth; <br /> } <br /> else if (window.innerWidth) { <br /> width = window.innerWidth - 18; <br /> } <br /> return width; <br /> } <br /> <br /> function getViewportHeight() { <br /> var height = 0; <br /> if (window.innerHeight) { <br /> height = window.innerHeight - 18; <br /> } <br /> else if (document.documentElement && document.documentElement.clientHeight) { <br /> height = document.documentElement.clientHeight; <br /> } <br /> else if (document.body && document.body.clientHeight) { <br /> height = document.body.clientHeight; <br /> } <br /> return height; <br /> } <br /> <br /> if (navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("MSIE 7") == -1 && navigator.userAgent.indexOf("MSIE 8") == -1) { <br /> window.ononload = window.onscroll = window.onresize = function (e) { <br /> var t = getViewportScrollY(); <br /> var l = getViewportScrollX(); <br /> var w = getViewportWidth(); <br /> var h = getViewportHeight(); <br /> document.getElementById("y1").style.left = l + "px"; <br /> document.getElementById("y1").style.top = t + "px"; <br /> <br /> document.getElementById("y2").style.left = l + w - document.getElementById("y2").offsetWidth + "px"; <br /> document.getElementById("y2").style.top = t + "px"; <br /> <br /> document.getElementById("y3").style.left = l + "px"; <br /> document.getElementById("y3").style.top = t + h - document.getElementById("y2").offsetHeight + "px"; <br /> <br /> document.getElementById("y4").style.left = l + w - document.getElementById("y2").offsetWidth + "px"; <br /> document.getElementById("y4").style.top = t + h - document.getElementById("y2").offsetHeight + "px"; <br /> } <br /> } <br /> </script>


左上角位置的内容

右上角位置的内容

左下角位置的内容

右下角位置的内容

a

a

a

a

a

a

a

a

a

a

a

a


a

a

a

a

a

a

a

a

a

a

a

a


a

a

a

a

a

a

a

a

a

a

a

a


a

a

a

a

a

a

a

a

a

a

a

a



来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板