如何创建一个iframe的目标链接也滚动到它? [英] How to make a target link to an iframe also scroll to it?
本文介绍了如何创建一个iframe的目标链接也滚动到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在我的iframe中打开网页并让它自动滚动到它?
换句话说...
我想知道如何结合这个:
Is there a way to open a web in my iframe and also make it auto scroll to it? In other words... I want to know how to combine this:
<a href="/example" target="myframe">
这个:
<a href="#myframe">
谢谢!
我不想要它在iframe中滚动到目标html中的anoche。事实上,iframe不允许滚动。我想在父(root web)中滚动到iframe
I dont want it to scroll within the iframe to an anoche within the target html. as a matter of fact the iframe doesnt have scrolling allowed. I want to scroll in the parent (root web) to the iframe
推荐答案
我找到了这个解决方案。完美无缺。
I found this solution. Works perfectly.
<a href="javascript:void(0)" onclick="IFrameScroll('http://www.asdf.com')">Class Name</a>
<script type="text/javascript">
function IFrameScroll(link){
window.myIframe.location=link;
window.location.hash='myIframe'
}
</script>
这篇关于如何创建一个iframe的目标链接也滚动到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文