Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

javascript - Directly link to page with specific content loaded in iframe

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?

Is there a simple html solution I'm missing or is this a jquery thing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Then you can use Javascript to check the parameter, and specify which page the iframe loads.

Here's an example jsbin.

https://output.jsbin.com/hawinadevi/1?iframePage=website_a Loads Bing

Change the value of website_a to make the iframe load Bandcamp instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...