Đối tượng HTML DOM IFrame
Đối tượng IFrame
Đối tượng IFrame đại diện cho một phần tử HTML <iframe>.
Truy cập một đối tượng IFrame
Bạn có thể truy cập một phần tử <iframe> bằng cách sử dụng getElementById ():
Thí dụ
var x = document.getElementById("myFrame");
Mẹo: Bạn cũng có thể truy cập phần tử <iframe> bằng cách sử dụng thuộc tính window.frames .
Tạo một đối tượng IFrame
Bạn có thể tạo một phần tử <iframe> bằng cách sử dụng phương thức document.createElement ():
Thí dụ
var x = document.createElement("IFRAME");
Thuộc tính đối tượng IFrame
Property | Description |
---|---|
align | Not supported in HTML5. Use style.cssFloat instead. Sets or returns the value of the align attribute in an iframe |
contentDocument | Returns the document object generated by an iframe |
contentWindow | Returns the window object generated by an iframe |
frameBorder | Not supported in HTML5. Use
style.border instead. Sets or returns the value of the frameborder attribute in an iframe |
height | Sets or returns the value of the height attribute in an iframe |
longDesc | Not supported in HTML5. Sets or returns the value of the longdesc attribute in an iframe |
marginHeight | Not supported in HTML5. Use style.margin instead. Sets or returns the value of the marginheight attribute in an iframe |
marginWidth | Not supported in HTML5. Use style.margin instead. Sets or returns the value of the marginwidth attribute in an iframe |
name | Sets or returns the value of the name attribute in an iframe |
sandbox | Returns the value of the sandbox attribute in an iframe |
scrolling | Not supported in HTML5. Sets or returns the value of the scrolling attribute in an iframe |
seamless | Sets or returns whether an iframe should look like it is a part of the containing document (no borders or scrollbars), or not |
src | Sets or returns the value of the src attribute in an iframe |
srcdoc | Sets or returns the value of the srcdoc attribute in an iframe |
width | Sets or returns the value of the width attribute in an iframe |
Thuộc tính và sự kiện tiêu chuẩn
Đối tượng IFrame cũng hỗ trợ các thuộc tính và sự kiện tiêu chuẩn .
Các trang liên quan
Tham chiếu HTML: thẻ HTML <iframe>