Home > Web Front-end > HTML Tutorial > Solution to js couplet ads not scrolling with the screen under div css_html/css_WEB-ITnose

Solution to js couplet ads not scrolling with the screen under div css_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:27:22
Original
1676 people have browsed it

" http://www.w3.org/TR/html4/loose.dtd">This sentence causes no scrolling, but if it is removed, it will be a disaster for websites developed with DIV CSS. We need to find another solution. There is some code in JS that does not comply with W3C standards

After looking for information, I found out that document.body does not meet the standards. Just replace it with document.documentElement. I wish I could commemorate the time I wasted


This article is reproduced from http://www.phpwind.net/read.php?tid=522770

The following is the original JS file, as long as it is called on the homepage, it will be OK.

function initEcAd() {

document.all.AdLayer1.style.posTop = -200;

document.all.AdLayer1.style.visibility = 'visible'

document.all. AdLayer2.style.posTop = -200;
document.all.AdLayer2.style.visibility = 'visible'
MoveLeftLayer('AdLayer1');
MoveRightLayer('AdLayer2');
}
function MoveLeftLayer(layerName) {
var x = 5;
var y = 84;//Height of the left ad from the top of the page
var diff = (document.documentElement.scrollTop y - document.all .AdLayer1.style.posTop)*.40;
var y = document.documentElement.scrollTop y - diff;
eval("document.all." layerName ".style.posTop = parseInt(y)") ;
eval("document.all." layerName ".style.posLeft = x");
setTimeout("MoveLeftLayer('AdLayer1');", 20);
}
function MoveRightLayer (layerName) {
var x = 5;
var y = 84;//Height of the right ad from the top of the page
var diff = (document.documentElement.scrollTop y - document.all.AdLayer2.style .posTop)*.40;
var y = document.documentElement.scrollTop y - diff;
eval("document.all." layerName ".style.posTop = y");
eval(" document.all." layerName ".style.posRight = x");
setTimeout("MoveRightLayer('AdLayer2');", 20);
}

document.write("< ;div id=AdLayer1 style='position: absolute;visibility:hidden;z-index:1'>< img src='/images/float.jpg' border='0' width=106 height=300>
         ;       ×

"
"");

initEcAd()


// JavaScript Document

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