Need to display iframe when link is clicked from menu

不羁岁月 提交于 2019-12-23 21:14:10

问题


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



来源:https://stackoverflow.com/questions/13411992/need-to-display-iframe-when-link-is-clicked-from-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!