The width attribute specifies the width of the embedded content in pixels.
The width
property sets or gets the width attribute in an <embed> element.
Embed width |
Yes | Yes | Yes | Yes | Yes |
Return the width property.
var v = embedObject.width
Set the width property.
embedObject.width=pixels
Value | Description |
---|---|
pixels | Set Specifies the width of the embedded content in pixels |
A Number type value representing the width of the embedded content in pixels.
The following code shows how to change the width of an embedded file to 100 pixels.
<!DOCTYPE html> <html> <body> <embed id="myEmbed" src="notExist.swf" width="200" height="200" style="border:1px solid"> <button onclick="myFunction()">test</button> <script> function myFunction() { document.getElementById("myEmbed").width = "100"; } </script> </body> </html>
The following code shows how to get the width of an embedded file.
<!DOCTYPE html> <html> <body> <embed id="myEmbed" src="notExist.swf" width="200" height="200" style="border:1px solid"> <p id="demo"></p> <button onclick="myFunction()">test</button> <script> function myFunction() { var x = document.getElementById("myEmbed").width; document.getElementById("demo").innerHTML = x; } </script> </body> </html>