Let’s complete the functions disassembled above first!
1. Transparent layer (show and hide)
The key is to set the following styles at the same time to achieve the transparent effect on mainstream browsers.
filter= 'Alpha(Opacity=50)';
MozOpacity ='0.5';
opacity='0.5';
Many people may know, Similar to this effect of realistic things on a transparent layer, there is an effect called lightbox. Here I also named it like this:
function Lightbox(id)
{
this.box = this.createBox();
this.id = id||'lightbox_id';
}
Lightbox.prototype=
{
createBox:function(){
var box = document.getElementById(this.id)||document.createElement('div');
box.id = box.id||this.id;
with(box.style){
position='absolute';
left='0';
top='0';
width='100%'; background='#ccc';
) '; 🎜> }
document.body.appendChild(box); box;
},
show:function(){
this.box.style.height= document.documentElement.scrollHeight+'px';
this.box.style.display = '';
},
hide:function(){
this.box.style.display = 'none';
}
}
2. Form submission (ajax or iframe)
Xunlei uses iframe. Let’s talk about iframe first.
iframe is much simpler. Just set the target attribute of the form to the name of an iframe. Set the onload attribute of the iframe, then it will perform corresponding processing after the form submission is completed.