Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Swap iframe src onClick.

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #44071
    djrolstad
    Participant

    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?

    #131616
    djrolstad
    Participant

    @Htmlmainiac, how would I do this if there were multiple links?

    #131621
    CrocoDillon
    Participant

    $(‘iframe’).attr(‘src’, $(this).attr(‘href’));

    Would work.

    #131624
    CrocoDillon
    Participant

    You can also give your iframe an id and your link that id as target:

    action link

    #131625
    djrolstad
    Participant

    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.

    #131627
    Anonymous
    Inactive

    You can do this without Javascript. Simply add target=”iframename” to any href link you want to display inside the iframe. Like this

    LINK

    My website works entirely on an iframe. [My Website](http://reallycoolstuff.net/PROJECTS/JV/ “”)

    #131631
    djrolstad
    Participant

    @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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.