Home > Web Front-end > HTML Tutorial > How can I freeze the picture that pops up with the following code? _html/css_WEB-ITnose

How can I freeze the picture that pops up with the following code? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:12:07
Original
1349 people have browsed it

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

 ");
document.writeln(""); 
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);


How to make the picture that pops up in the lower right corner stay fixed, which means that no matter how the drop-down box is pulled, the picture will not move!


回复讨论(解决方案)

你可以参考





html,body{margin:0;padding:0;}
#y1 {position:fixed;top:0;left:0;width:100px;height:100px;border:1px solid red;}
#y2 {position:fixed;top:0;right:0;width:100px;height:100px;border:1px solid red;}
#y3 {position:fixed;bottom:0;left:0;width:100px;height:100px;border:1px solid red;}
#y4 {position:fixed;bottom:0;right:0;width:100px;height:100px;border:1px solid red;}




  //以下所有脚本只为IE6写,其他浏览器完全可以删除。
  function getViewportScrollX() {
    var scrollX = 0;
    if (document.documentElement && document.documentElement.scrollLeft) {
      scrollX = document.documentElement.scrollLeft;
    }
    else if (document.body && document.body.scrollLeft) {
      scrollX = document.body.scrollLeft;
    }
    else if (window.pageXOffset) {
      scrollX = window.pageXOffset;
    }
    else if (window.scrollX) {
      scrollX = window.scrollX;
    }
    return scrollX;
  }

  function getViewportScrollY() {
    var scrollY = 0;
    if (document.documentElement && document.documentElement.scrollTop) {
      scrollY = document.documentElement.scrollTop;
    }
    else if (document.body && document.body.scrollTop) {
      scrollY = document.body.scrollTop;
    }
    else if (window.pageYOffset) {
      scrollY = window.pageYOffset;
    }
    else if (window.scrollY) {
      scrollY = window.scrollY;
    }
    return scrollY;
  }

  function getViewportWidth() {
    var width = 0;
    if (document.documentElement && document.documentElement.clientWidth) {
      width = document.documentElement.clientWidth;
    }
    else if (document.body && document.body.clientWidth) {
      width = document.body.clientWidth;
    }
    else if (window.innerWidth) {
      width = window.innerWidth - 18;
    }
    return width;
  }

  function getViewportHeight() {
    var height = 0;
    if (window.innerHeight) {
      height = window.innerHeight - 18;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
      height = document.documentElement.clientHeight;
    }
    else if (document.body && document.body.clientHeight) {
      height = document.body.clientHeight;
    }
    return height;
  }

  if (navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("MSIE 7") == -1 && navigator.userAgent.indexOf("MSIE 8") == -1) {
    window.ononload = window.onscroll = window.onresize = function (e) {
      var t = getViewportScrollY();
      var l = getViewportScrollX();
      var w = getViewportWidth();
      var h = getViewportHeight();
      document.getElementById("y1").style.left = l + "px";
      document.getElementById("y1").style.top = t + "px";

      document.getElementById("y2").style.left = l + w - document.getElementById("y2").offsetWidth + "px";
      document.getElementById("y2").style.top = t + "px";

      document.getElementById("y3").style.left = l + "px";
      document.getElementById("y3").style.top = t + h - document.getElementById("y2").offsetHeight + "px";

      document.getElementById("y4").style.left = l + w - document.getElementById("y2").offsetWidth + "px";
      document.getElementById("y4").style.top = t + h - document.getElementById("y2").offsetHeight + "px";
    }
  }



左上角位置的内容

右上角位置的内容

左下角位置的内容

右下角位置的内容

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



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template