簡體   English   中英

HTML jQuery獲取iFrame內部的元素寬度?

[英]HTML JQuery Get Element Width Inside of iFrame?

在頁面上顯示此iframe:

<iframe name="fileFrame" id="fileFrame" class="fileFrame" style="display:none;" src="http://example.com" height="50%" width="50%"></iframe>

iframe中有一個元素是從其他網站提取的:

<div class="progress-bar" style="display:block; width: 18%;"></div>

如何獲取主頁以拉動進度條的寬度?

嘗試跟蹤此進度,以使進度條在iframe中加載完成(100%)后即可更新主頁。

嘗試了一下,但是沒有用:

var mydivw = $("#fileFrame").contents().find(".progress-bar").width();
alert(mydivw);

這樣嘗試

$("#fileFrame").contents().find(".progress-bar").width()

你可以把它裝上

像這樣

$("#fileFrame").on("load",function(){

  var width=$(this).contents().find(".progress-bar").width()

})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM