0
我有一个iFrame,当加载时伸展他的整个长度没有滚动条。
1秒钟后,我想滚动到iFrame中的锚点。jQuery的内容()找到iFrame中锚链接的页面高度
我想我需要得到它的高度?
我该怎么做?
HTML:
<iframe id="help-frame" src="help.php" scrolling="no"><\/iframe>
JS:
$("#help-frame").load(function() {
document.getElementById("help-frame").style.height =
document.getElementById("help-frame").contentWindow.document.body.offsetHeight + 'px';
setTimeout(iScroll, 1000);
});
function iScroll() {
var anchorH = $("#help-frame").contents().find("a.ordering").height();
alert(anchorH);
// smooth scroll to #ordering
}
HTML help.php:
<!-- added a class as well -->
<a name="ordering" class="ordering"></a>
<h2>Ordering</h2>
... long content ...
谢谢安迪,这个包还有更多的技巧。因为我宁愿要动画主页,而不是iFrame内容(没有滚动条,100%的高度)我使用$(“html,body”)。animate() – FFish 2010-10-04 09:33:00
有没有办法找到name =“ordering”的类btw? – FFish 2010-10-04 11:33:41
@FFish:如果name是一个属性,你可以用$('a [name = ordering]')来查询它。 – jAndy 2010-10-04 11:53:03