0
A
回答
2
使用jQuery:
$('iframe').height();
$('iframe').width();
编辑 在阐述上述快速和肮脏的答案。 .height()
和.width()
会给你的元素的高度和宽度没有填充,边框或边距。
如果你想包括填充和边框,你将需要使用.innerHeight()
和.innerWidth()
。下面的示例:
$('iframe').innerHeight();
$('iframe').innerWidth();
如果你想包括填充和边界,你将需要使用.outerHeight()
和.outerWidth()
保证金。实施例下面:
$('iframe').outerHeight();
$('iframe').outerWidth();
链接上述方法:
https://api.jquery.com/height/
https://api.jquery.com/innerHeight/
https://api.jquery.com/outerHeight/
https://api.jquery.com/width/
https://api.jquery.com/innerWidth/
https://api.jquery.com/outerWidth/
0
使用纯javascript:
document.getElementsByTagName('iframe')[0].getAttribute('width');
document.getElementsByTagName('iframe')[0].getAttribute('height');
相关问题
- 1. 获取iframe的高度和宽度
- 2. 获取高度和宽度
- 3. 从javascript的iframe中获取src的宽度和高度
- 4. Android |获取屏幕高度,宽度和屏幕宽度,高度
- 5. 如何获取Canvas的宽度/高度?
- 6. 获取图像的宽度和高度
- 7. 获取文档的宽度和高度
- 8. 获取UIElement的高度和宽度?
- 9. 获取宽度和高度的布局
- 10. 获取图像的宽度和高度
- 11. 获取applet的高度和宽度
- 12. 获取图像的宽度和高度
- 13. 获取元素的宽度和高度
- 14. iframe的高度和宽度居中
- 15. iframe的宽度和高度值
- 16. 在OnDocumentComplete中获取iFrame宽度和高度出错
- 17. iframe src全宽和高度
- 18. 获取图片高度和宽度
- 19. Java JPanel JFrame获取高度和宽度
- 20. 获取屏幕高度和宽度
- 21. 获取父宽度和高度
- 22. Android,获取屏幕宽度和高度?
- 23. 获取屏幕宽度和高度
- 24. jQuery获取高度和宽度
- 25. Iframe宽度和高度不会改变
- 26. setRotationX/setRotationY宽度/高度增加后。如何获得新的宽度和高度?
- 27. 获取iframe的高度
- 28. 获取iframe的高度
- 29. 如何获取iframe内容宽度?
- 30. 如何获取未设置宽度和高度的img元素的宽度和高度?