Forums

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

Home Forums JavaScript Jquery and iframe fun

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #168093
    fooman
    Participant

    I have a simple iframe that displays a list of database records.

    <iframe id="podcast-list-frame" class="podcast-list" src="podcast-listing"></iframe>

    This shows up fine and all that. I then want to know if a table row was clicked inside the iframe so I use
    $("#podcast-list-frame").contents().find("tr");
    However, when I try to use that with the click() event, nothing ever gets triggered.

    I try to register a click event with the iframe itself and nothing gets triggered. When I change click() to mouseenter() it indeed works.

    Any ideas? It seems like a simple thing but I can’t figure out what I’m doing wrong :(

    #168129
    Podders
    Participant

    Hi @fooman

    I have a feeling it may be to do with timing and when your actually attaching the click handlers

    If you attach the click handler before the iframe has actually loaded then it will never fire, you need to attach the handler after the iframe has loaded,

    check out http://codepen.io/Podders/pen/mrvcH/ for a demo

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