たとえば、次のようなものがあります。
<iframe width="700px" src="/top_list.html"></iframe>
このフレームから table .. 以外のすべてを削除するにはどうすればよいですか? または、ユーザーがそのページからテーブルのコンテンツのみを表示するにはどうすればよいですか?
たとえば、次のようなものがあります。
<iframe width="700px" src="/top_list.html"></iframe>
このフレームから table .. 以外のすべてを削除するにはどうすればよいですか? または、ユーザーがそのページからテーブルのコンテンツのみを表示するにはどうすればよいで
一意の識別子がなく、top_listページを変更できない場合は、jquery .hide()を使用して、表示したくないものをすべて非表示にすることができます。
いくつかのjqueryツールが必要です。
.main
私の例は、クエリについて非常に明確です。連鎖がないので、何が起こっているかを見ることができます。お役に立てば幸いです。
$(window).on('load', function() // wait for load event, so the iframe is fully loaded in
{
var $iframe = $('iframe'); // assuming only one? You need to target the right iframe, perahps with iframe[src="/top_list.html"] if that's your only option
var $contents = $iframe.contents();
var $main = $contents.find('.main');
var $tbl = $main.next(); // now we have the table
$contents.find('*').hide(); // hide everything
$tbl.show(); // show table and...
var $parent = $tbl.parent(); // get/show all parents of the tbl
while($parent.length)
{
$parent.show(); // show parent
$parent = $parent.parent(); // move up the hierarchy
}
});