1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Jquery iframe little help required urgently

Discussion in 'jQuery' started by hallianonline, Apr 27, 2014.

  1. #1
    Hello every one i have an issue that
    I have a single page website which includes an iframe in it, when iframe load it contains a table which i want to hide and this table also repeats on multiple pages
    so I want to add a code in my main page header which finds this content from iframe and hide it if even iframes loads new pages the code which i want to hide is

    <table cellSpacing="0" cellPadding="0" border="0">
        <tr>
            <td width="225"><a id="_ctl0_ucMNB_logo_LogoHyperLink" href="#"><img id="_ctl0_ucMNB_logo_imgLeftPart" class="header_logo_img" src="#" border="0" /></a></td>
           
           
        </tr>
    </table>
    HTML:
     
    hallianonline, Apr 27, 2014 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    iframes you say... what is this, 1997? (the last time they were valid)

    While I'm having a devil of a time figuring out what you are even asking, (or why you seem to be wasting a table on obviously non-tabular content) -- the "header which finds this content from iframe" sounds like one of the things that is intentionally BLOCKED by browsers as it makes it too easy to make cross-site scripting exploits. Part of why in all but the rarest of cases frames are a decade and a half old relic that has no business on a modern website.
     
    deathshadow, Apr 30, 2014 IP
  3. somasounds

    somasounds Member

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    While iframes may not be officially valid, they are still used on a large percentage of the internet.

    @hallianonline, what you need is two-fold: to listen for changes in the iframe content and to change the table inside the iframe.

    If you want to access the iframe, get it's id and use

    $("#theiframeID").on('load', function() { 
        $("table tr td").html(); //or however you see fit 
    
    })
    
    Code (markup):
    You could listen for changes to the iframe src with a simple setTimeout() function as well.
     
    somasounds, May 22, 2014 IP
  4. mikejwatson

    mikejwatson Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    13
    #4
    Sounds good Somasounds,

    You could also add an ID to the table that you want to hide e.g. <table id="myTable">

    and in your jquery do $('#myTable').css('display','none');

    That way you're hiding the whole table, rather than removing the content from between the table tags.

    If you're unable to add an ID to the table, you could instead try this:

    $('#_ctl0_ucMNB_logo_LogoHyperLink').css('display','none');
    $('#_ctl0_ucMNB_logo_imgLeftPart').css('display','none');

    This will ensure that both the link and image are hidden, and since that is the only content in the table it should no longer be visible (unless it's styled with background, borders etc.)
     
    mikejwatson, May 22, 2014 IP
  5. mikejwatson

    mikejwatson Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    13
    #5
    Another thought... You could also add some simple css styling:

    <style>
    #_ctl0_ucMNB_logo_LogoHyperLink, #_ctl0_ucMNB_logo_imgLeftPart {
    display: none;
    }
    </style>

    This might do the trick
     
    mikejwatson, May 22, 2014 IP