我有一个使用 SCORM 文件加载的 iframe。 SCORM 文件加载了很多内容,但我唯一需要获取的是嵌入元素的 ID 以更改其高度。我尝试使用 .css()
方法更改高度,但没有成功。以下是突出显示目标元素的源图像。
到目前为止我试过这个:
$('.scorm').contents().find('#scorm_iframe').contents().find('frameset').find('frame').get(0).contentWindow.document.all[16];
但我只得到div id="divSwf"
非常感谢。
最佳答案
除了 innerHeight
之外,还有一些其他方法可以使用.您可以使用 height
或 outerHeight
以及。请记住,结果取决于您使用的是什么。
$(function() {
var H = 500;
$('#scorm_content').load(function() {
$('#scorm_content').contents().find("#eplayer").innerHeight(H);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<iframe id="scorm_content" src="/"></iframe>
<!-- This is Pseudo code of the page within the iframe
<table...
<tbody...
<tr...
<td...
<div....
<object...
<embed id="eplayer" .... -->
关于javascript - 使用 jQuery 在框架中获取嵌入 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34757153/