IFrame width Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame


The width property sets or gets the width attribute in an iframe element.

Set the width property with the following Values

Value Description
pixels The width in pixels ("100px" or just "100")

Return Value

A String, representing the width of the iframe, in pixels

The following code shows how to change the width of an iframe:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<iframe id="myFrame" src="http://java2s.com" height="200" width="250"></iframe>

<button onclick="myFunction()">Test</button>

function myFunction() {//w  w w .  ja  v  a  2 s. co  m
    document.getElementById("myFrame").width = "400";


Related Tutorials