Better alternative to an iframe?

前端 未结 8 1600
臣服心动
臣服心动 2020-12-05 03:20

I have a page with an iframe to feature the contents of the clicked tab. There are 3 tabs and 1 iframe. The sources of the contents relating to each tab clicked are formatte

8条回答
  •  时光取名叫无心
    2020-12-05 03:24

    As mentioned, you could use jQuery or another library to retrieve the contents of the HTML file and populate it into the div. Then you could even do a fancy fade to make it look all pretty.

    http://docs.jquery.com/Ajax/jQuery.get

    Something along these lines:

    $.get("toframe.html", function(data){
      $("#tabs-1").html(data);
    });
    

    edit.. you could prepopulate or onclick you could do the get dynamically

    $("#tabs a").click(function(){
       var pagetoget = $(this).attr("href");
       $.get...
    })
    

    If you prepopulate could have three containers instead of the one you have now, 2 hidden, 1 display, and the click functions will hide them all except for the one you want.

    The get is less code though, easier time.

提交回复
热议问题