简体   繁体   中英

how to get the top left coordinates of the screen with javascript on firefox

I have a <div> element with position: absolute and z-index something big. I would like to cover the entire screen with this div with javascript. This is what I do and it works:

document.getElementById('mydiv').style.top = 0;
document.getElementById('mydiv').style.left = 0;
document.getElementById('mydiv').style.width = '100%';
document.getElementById('mydiv').style.height = '100%';

However, when I scroll down with long webpages, this code displays my div at the top of the page, so the div renders above the region I currently view. How can I change the top and left values so that my div always covers the active field I am viewing?

I work on firefox 3.6.*.

Thank you

Change it to position: fixed .

Note that this won't work in IE6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM