How extract links from iframe using javascript

前端 未结 2 2012
悲哀的现实
悲哀的现实 2020-12-21 22:22

Example:

iframe.html

Google
bla bla bla
Yahoo
         


        
2条回答
  •  一整个雨季
    2020-12-21 22:55

    Assuming your iframe is on the same domain as your website, and has the id "my_iframe" and you have a div with the id "results", this should work for you:

    $("#my_iframe").contents().find('a').each({
        $('#results').append($(this).attr('href') + '
    '); });

    Take a moment to read up on JQuery's .contents() function.

提交回复
热议问题