直接链接到在 iframe 中加载特定内容的页面 [英] Directly link to page with specific content loaded in iframe
问题描述
我有一个带有加载不同内容的 iframe 的首页.我想要一个 url,它将把用户带到在 iframe 中加载 pageA 或加载了 pageb 的另一个 url 的首页.我该怎么做?
I have a front page with an iframe that loads different content. I want a url that will take users to the front page with pageA loaded in the iframe or another url with pageb loaded. How do I do this?
是否有我遗漏的简单 html 解决方案,或者这是一个 jquery 问题?
Is there a simple html solution I'm missing or is this a jquery thing?
推荐答案
您可以使用查询参数来指定您希望 iframe 加载的页面.
You can use a query parameter to specify the page you want the iframe to load.
www.example.com/my/link/page.html?iframePage=website_a
www.example.com/my/link/page.html?iframePage=website_a
然后可以使用Javascript检查参数,并指定iframe加载哪个页面.
Then you can use Javascript to check the parameter, and specify which page the iframe loads.
这是一个示例 jsbin.
https://output.jsbin.com/hawinadevi/1?iframePage=website_a 加载 Bing
更改 website_a
的值以使 iframe 加载 Bandcamp.
Change the value of website_a
to make the iframe load Bandcamp instead.
这篇关于直接链接到在 iframe 中加载特定内容的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!