想做一个弹出页面并且给该页面动态加载一个Flash(弹出页面的地址是空白页)
现在Chrome是可以的,但是IE下不行。代码如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="C:/Users/SylarSun/Desktop/sssss/jquery.js"></script>
<title>123123123</title>
</head><body>
<script type="text/javascript">
var swf=document.createElement("embed");
swf.setAttribute("width","160");
swf.setAttribute("height","109");
swf.setAttribute("align","middle");
swf.setAttribute("type","application/x-shockwave-flash");
swf.setAttribute("allowscriptaccess","always");
swf.setAttribute("quality","high");
swf.setAttribute("src","https://mssl.chinauma.net:446/media/uploads/14/2012-09-28/13488354947719.swf");
swf.setAttribute("wmode","transparent");
// document.appendChild(swf);
var a = document.createElement("A");
var linkStyle = "position:absolute;top:0;left:0;bottom:0;right:0;display:block;width:100%;height:expression(this.parentNode.scrollHeight);filter:alpha(opacity=0);opacity:0;background:#FFF;";
a.style.cssText = linkStyle;
a.target = "_target";
a.href = "http://www.baidu.com"; var div = document.createElement("DIV");
style="font-size:0;position:relative;width:"+160+"px;height:"+109+"px;";
div.style.cssText = style;
div.appendChild(a);
div.appendChild(swf);
window.open("about:blank").document.body.appendChild(div);
</script></body>
</html>请高手指教下!
现在Chrome是可以的,但是IE下不行。代码如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="C:/Users/SylarSun/Desktop/sssss/jquery.js"></script>
<title>123123123</title>
</head><body>
<script type="text/javascript">
var swf=document.createElement("embed");
swf.setAttribute("width","160");
swf.setAttribute("height","109");
swf.setAttribute("align","middle");
swf.setAttribute("type","application/x-shockwave-flash");
swf.setAttribute("allowscriptaccess","always");
swf.setAttribute("quality","high");
swf.setAttribute("src","https://mssl.chinauma.net:446/media/uploads/14/2012-09-28/13488354947719.swf");
swf.setAttribute("wmode","transparent");
// document.appendChild(swf);
var a = document.createElement("A");
var linkStyle = "position:absolute;top:0;left:0;bottom:0;right:0;display:block;width:100%;height:expression(this.parentNode.scrollHeight);filter:alpha(opacity=0);opacity:0;background:#FFF;";
a.style.cssText = linkStyle;
a.target = "_target";
a.href = "http://www.baidu.com"; var div = document.createElement("DIV");
style="font-size:0;position:relative;width:"+160+"px;height:"+109+"px;";
div.style.cssText = style;
div.appendChild(a);
div.appendChild(swf);
window.open("about:blank").document.body.appendChild(div);
</script></body>
</html>请高手指教下!
当window.open之后,就不受我的控制了。
<body id="bodyelement">
<script type="text/javascript">
var swf=document.createElement("embed");
swf.setAttribute("width","160");
swf.setAttribute("height","109");
swf.setAttribute("align","middle");
swf.setAttribute("type","application/x-shockwave-flash");
swf.setAttribute("allowscriptaccess","always");
swf.setAttribute("quality","high");
swf.setAttribute("src","https://mssl.chinauma.net:446/media/uploads/14/2012-09-28/13488354947719.swf");
swf.setAttribute("wmode","transparent");var insertid =document.getElementById("bodyelement");
insertid.appendChild(swf);
</script>
function init1()
{
var swf1=document.createElement("embed");
swf1.setAttribute("width","260");
swf1.setAttribute("height","109");
swf1.setAttribute("align","middle");
swf1.setAttribute("type","application/x-shockwave-flash");
swf1.setAttribute("allowscriptaccess","always");
swf1.setAttribute("quality","high");
swf1.setAttribute("src","https://mssl.chinauma.net:446/media/uploads/14/2012-09-28/13488354947719.swf");
swf1.setAttribute("wmode","transparent");var a = document.createElement("A");
var linkStyle = "position:absolute;top:0;left:0;bottom:0;right:0;display:block;width:100%;height:expression(this.parentNode.scrollHeight);filter:alpha(opacity=0);opacity:0;background:#FFF;";
a.style.cssText = linkStyle;
a.target = "_target";
a.href = "http://www.baidu.com";var div = document.createElement("DIV");
style="font-size:0;position:relative;width:"+160+"px;height:"+109+"px;";
div.style.cssText = style;
div.appendChild(a);
//div.appendChild(swf1);
window.open("about:blank").document.body.appendChild(div);//documnet.appendChild(swf);
}
window.onload=init1;
</script>
新打开的页面不是一个物理文件,不在我的服务器上
我是动态的去生成,就是window.open('about:blank'...)这种方式
是有body的,也添加成功了一些元素.
可是现在遇到了一个问题,就是我想插入一个Flash,他不显示
我猜想是他没有加载FlashPlayer插件 这个怎么弄呢
flash插件不加载是ie设置里的问题吧
但是不加载FlashPlayer. 哎 郁闷
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="C:/Users/SylarSun/Desktop/sssss/jquery.js"></script>
<title>123123123</title>
</head><body>
<script type="text/javascript">
var swf = document.createElement("embed");
swf.setAttribute("width", "160");
swf.setAttribute("height", "109");
swf.setAttribute("align", "middle");
swf.setAttribute("type", "application/x-shockwave-flash");
swf.setAttribute("allowscriptaccess", "always");
swf.setAttribute("quality", "high");
swf.setAttribute("src", "https://mssl.chinauma.net:446/media/uploads/14/2012-09-28/13488354947719.swf");
swf.setAttribute("wmode", "transparent");
// document.appendChild(swf); var a = document.createElement("A");
var linkStyle = "position:absolute;top:0;left:0;bottom:0;right:0;display:block;width:100%;height:expression(this.parentNode.scrollHeight);filter:alpha(opacity=0);opacity:0;background:#FFF;";
a.style.cssText = linkStyle;
a.target = "_target";
a.href = "http://www.baidu.com"; var div = document.createElement("DIV");
style = "font-size:0;position:relative;width:" + 160 + "px;height:" + 109 + "px;";
div.style.cssText = style;
div.appendChild(a);
div.appendChild(swf); var fragment = document.createElement('fragment');
fragment.appendChild(div); var win = window.open("about:blank")//.document.body.appendChild(div);
win.document.open();
win.document.write(fragment.innerHTML);
win.document.close();
</script></body>
</html>
顺便问一下怎么给一个iframe write一个元素呢?
ie8和9都不一样
<script type="text/javascript"> window.onload = function () {
var doc = document.getElementById('ifr').contentWindow.document;
doc.open();
doc.write(new Date());
doc.close();
}
</script>
请问这个doc.open是什么思路呢? 太厉害了...