[英]How can I get the value of an attribute inside an iframe from parent in Javascript?
[英]how can i change the parent iframe size from inside with javascript?
我們有一個 ReactJs 代碼,它將在網站中作為 iframe 運行,問題是我們有很多客戶端將 iframe 高度設置為 700px 作為默認值,我們不能告訴他們所有人都更改它,我們也無法訪問iframe。 這將使我們的項目可滾動。 我們希望在沒有從內部滾動的情況下使其全尺寸。
<iframe width="100%" height="700" src="url" frameborder="0" id="myIframe" scrolling="no"></iframe>
我想您應該將寬度和高度的單位從%更改為與所有設備兼容的視口,例如:將寬度設置為100vw
,這將設置 iframe 的寬度以覆蓋整個視口寬度,因此寬度將是動態的,高度設置也是如此將它設置為100vh
還可以添加樣式,刪除該 iframe 的寬度和高度屬性,並添加與以下內容相同的內聯樣式,
<iframe style="width: 100vw; height:100vh" src="url" frameborder="0" id="myIframe" scrolling="no"></iframe>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.