开发者

Set applet width with javascript

开发者 https://www.devze.com 2023-02-01 04:13 出处:网络
I want to set the w开发者_Python百科idth of an applet with the width of the div that he is in. How can I do that?Assuming applet has an id of \"myApplet\":

I want to set the w开发者_Python百科idth of an applet with the width of the div that he is in. How can I do that?


Assuming applet has an id of "myApplet":

Note: This will only work if the div element's width is set directly on the element (not using a stylesheet)

var myApplet = document.getElementById("myApplet");
myApplet.width = myApplet.parentNode.style.width;


<applet id="foo" ...></applet>

...

var app = document.getElementById('foo');
app.width = app.parentNode.offsetWidth;
0

精彩评论

暂无评论...
验证码 换一张
取 消