- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Swap iframe src onClick.
http://codepen.io/anon/pen/kAgba
I’m trying to switch iFrame source when the user clicks on action link but its not working.. Is there another way maybe jQuery?
@Htmlmainiac, how would I do this if there were multiple links?
$(‘iframe’).attr(‘src’, $(this).attr(‘href’));
Would work.
You can also give your iframe an id and your link that id as target:
I was actually giving the a href a class therefore I can have the links point to different “sites”. But I don’t know how to modify the JS so it would allow multiple links.
You can do this without Javascript. Simply add target=”iframename” to any href link you want to display inside the iframe. Like this
My website works entirely on an iframe. [My Website](http://reallycoolstuff.net/PROJECTS/JV/ “”)
@Jarolin and @CrocoDillon, that is actually easier haha THANKS!
@Htmlmainiac, Thanks! I’m actually trying to figure JavaScript out it’s for some reason hard for me.