通过IFRAME - jQuery / PHP引用url中的特定TAG

时间:2017-03-16 07:52:43

标签: php jquery ajax iframe iframe-resizer

我想知道我是否可以通过iframe中的链接定向(Src)引用特定标记(在我们的示例H1中)。

例如,链接http://www.marketwatch.com/story/what-the-fed-raising-rates-would-mean-for-your-credit-cards-and-bank-accounts-2016-12-14

我想知道我是否可以参考以下链接中的第一个H1(“美联储加息将如何影响数百万美国人”)。主要目标是直接查看该文章。

<iframe id="iFrame1" scrolling="no" src="http://www.marketwatch.com/story/what-the-fed-raising-rates-would-mean-for-your-credit-cards-and-bank-accounts-2016-12-14#H1" style="overflow: scroll; -webkit-overflow-scrolling: touch;" sandbox=""></iframe>
  • '参考h1标签'是什么意思?我的意思是我想将iframe向下滚动到该元素。
  • 这个想法是直接指向没有ID或CLASS的特定TAG(H1ׂ)(所有世界站点中的所有文章只有一个H1)。

1 个答案:

答案 0 :(得分:0)

假设您希望iframe向下滚动到h1标记,则可以向URL添加一个与所需元素的id属性匹配的片段。在这种情况下,它是#article-headline。试试这个:

<iframe id="iFrame1" scrolling="no" src="http://www.marketwatch.com/story/what-the-fed-raising-rates-would-mean-for-your-credit-cards-and-bank-accounts-2016-12-14#article-headline" style="overflow: scroll; -webkit-overflow-scrolling: touch;" sandbox=""></iframe>