Need to display iframe when link is clicked from m

2019-07-15 10:44发布

问题:

I am creating a website which can display a bunch of playlists I have created on 8tracks. Lets say I have 10 playlists; I want to be able to link to that iframe playlist (via the embed code which 8tracks provides) like this: http://d.pr/i/FBxn

Essentially I want the iframe to change based on which mixtape link I click on the menu (a playlist of playlists*)

I am new to JS and would appreciate anyhelp. I'm still trying to grasp the relationship between HTML and JS so this is a new area for me. Thanks so much.

回答1:

You can setup anchors to target a specific iframe:

Give a name to your iframe (playframe), and set the 'src' to the default playlist (displayed when iframe is rendered)

<iframe name='playframe' src='http://path/to/playlist/1'></iframe>

Then target your links to playframe

<a href='http://path/to/playlist/1' target='playframe'>Playlist 1</a>​
<a href='http://path/to/playlist/2' target='playframe'>Playlist 2</a>​


回答2:

InnerHTML could help you. Please refer http://www.w3schools.com/jsref/prop_html_innerhtml.asp