javascript flash 弹框

1. [代码]FlashBox     
// JavaScript Document
function FlashBox(src,width,height){
var docbody = document.body; 
var _w = docbody.offsetWidth; 
var _x = parseInt((_w-width) / 2);



var screendiv = document.createElement("div");
screendiv.style.cssText = 'width:100%; height:100%; bottom:0; background:#000; filter:Alpha(opacity=80);opacity:0.8; z-index:998;position:fixed;_position:absolute;z-index:10;top:0;_top:expression(eval(document.documentElement.scrollTop));';http://www.huiyi8.com/css3/


var panel = document.createElement("div");
panel.style.cssText = ' position:absolute; z-index:999; left:'+ _x +'px;  width:'+width+'px; height:'+height+'px; position:fixed;_position:absolute;z-index:10;top:200px;_top:expression(eval(document.documentElement.scrollTop+200)+"px"); border:3px solid #000; ';

var close = document.createElement("div");
close.style.cssText = 'position:absolute; z-index:999; top:-24px; right:-24px; width:30px; cursor:pointer; height:30px; background:url(closebox.png)';


var iframe= document.createElement("iframe"); 
iframe.style.cssText = 'display:block; width:100%; height:100%';
iframe.width = iframe.height = "100%"; 
iframe.scrolling="no";css3教程
iframe.setAttribute("frameborder","0");

panel.appendChild(close);
panel.appendChild(iframe);


docbody.appendChild(screendiv);
docbody.appendChild(panel);


var newDoc = iframe.contentWindow.document.open("text/html","replace");
var txt = '<html><style type="text/css">*{ margin:0; padding:0}</style><body>'+
'<embed height="'+height+'" width="'+width+'" src="'+src+
'" type="application/x-shockwave-flash" scale="showall" play="true" loop="true" menu="true"></embed></body></html>'; 

newDoc.write(txt);
newDoc.close();

close.onclick=function(){ 
panel.parentNode.removeChild(panel);
screendiv.parentNode.removeChild(screendiv); 
} 

}
//demo
FlashBox('http://player.youku.com/player.php/Type/Folder/Fid/15455979/Ob/1/Pt/0/sid/XMzA1NzIwMTI4/v.swf',600,400);

posted @ 2014-07-04 14:46  虚空之眼  阅读(262)  评论(0编辑  收藏  举报