滑入滑出效果的弹出窗口

<script>
var movwin,targetX,step
function newwin(w,h){
movwin=window.open("","demo","width="+w+",height="+h)
movwin.document.write(subwin.innerHTML)
movwin.document.close()
targetX=(screen.width-w)/2
step=(targetX-movwin.screenLeft)/10
movwin.moveTo(-w,(screen.height-h)/2)
moveit()
}
function moveit(){
if(!movwin.closed&&movwin.screenLeft<targetX){
   movwin.moveBy(step,0)
   setTimeout("moveit()",10)
   step=(targetX-movwin.screenLeft)/10
}
}
</script>
<button onClick="newwin(150,100)">打开滑动窗口</button>
<xmp style="display:none" id="subwin">
<script>
var step=0.1
function closeit(){
if(screenLeft<screen.width) {
  step*=1.15
  self.moveBy(step,0)
  setTimeout("closeit()",10)
}
else self.close()
}
</script> <br><a target=_blank href=http://www.7788ok.com/blog>my bolg</a>
<button onClick="closeit()">关闭滑动窗口</button>
</xmp>

你可能感兴趣的:(弹出窗口)