我正在尝试覆盖由iframe创建的以下<object>
宽度和高度值 - 下面是我尝试覆盖它的JS代码段,但在控制台中它返回错误 未捕获的TypeError:无法设置null的属性'height'
<object type="application/x-shockwave-flash" id="videoPlayerSWF" data="http://videoplayer.vevo.com/embed/embedded" width="1794" height="1082"><param name="bgcolor" value="#000000"></object>
document.getElementById("videoPlayerSWF").height='100%';
document.getElementById("videoPlayerSWF").width='100%';
答案 0 :(得分:0)
window.onload = function(){
document.getElementById("videoPlayerSWF").height='100%';
document.getElementById("videoPlayerSWF").width='100%';
}
http://jsfiddle.net/acrashik/YLJa7/2/
答案 1 :(得分:-4)
试试这个
document.getElementById("videoPlayerSWF").style.width = "100%";