javascript控制网页背景图片

xiaoxiao2021-02-28  116

HTML部分:

CSS: #loginImg{ position:absolute; top:0px; left:0px; z-index:-999px; }

JavaScript:

window.οnresize=window.οnlοad=function(){ var width_,height_; if(!!((var name = navigator.appName) == "Microsoft Internet Explorer")) /*Microsoft Internet explorer浏览器*/ { if(!!(window.attachEvent && ! window.opera)) { width_=document.documentElement.clientWidth; height_=document.documentElement.clientHeight; } else{ height_=window.innerHeight; width_=window.innerWidth; } } /*Firefox浏览器*/ else if(name = "Netscape") { window.οnresize=window.load=function(){ var width_,height_; if(!!(window.addEventListener && ! window.opera)) { width_ = document.documentElement.clientWidth; height_ = document.documentElement.clientHeight; } else{ height_=window.innerHeight; width_= window.innerWidth; } } } var login=document.getElementById('loginImg').getElementsByTagName('img')[0]; login.width=(width_-5); login.height=(height_-5); }
转载请注明原文地址: https://www.6miu.com/read-36171.html

最新回复(0)