本文範例講述了JS取得iframe中marginHeight和marginWidth屬性的方法。分享給大家供大家參考。具體如下:
<!DOCTYPE html> <html> <body> <iframe id="myframe" src="demo_iframe.htm" marginheight="50" marginwidth="50"> <p>Your browser does not support iframes.</p> </iframe> <br><br> <p>The value of the marginheight attribute and marginwidth are: <script> document.write(document.getElementById("myframe").marginHeight); document.write(document.getElementById("myframe").marginWidth); </script> <p> </body> </html>
希望本文所述對大家的javascript程式設計有所幫助。