Loading external sites into Iframe dynamically - i

2019-03-03 12:24发布

问题:

I've build an application which currently uses an Iframe to load external sites.

This method is really slowing my application down - taking up to 5 seconds to load a page that might load in <1sec in it's own tab/window.

Is there any solution I can implement which will let get more speed?!?

Thanks!

EDIT:

Here's the code I'm currently using:

<script type="text/javascript">

// Change iFrame on a Button Click Event
$("#myButton").click(function(event){            
    $("#myIFrame").attr('src', $('#url').val());
});

</script>

<input class="url_top" type="text" id="url" value="http://">
<a id="myButton" href="#">Load</a> 
<iframe id="myIFrame" height="80%" width="100%" class="netframe" src="page.php"></iframe>

回答1:

@Simon, if you are loading sites into an iFrame then you are probably doing a thumbnail right? Doing this is going to be slow as each page needs to render in yours so you are contending with the speed of the external site by a factor of n where n is the number of sites on your page.

Please provide more info on what the outcome is that you want so that the greatter community can advise on perhaps different tactics.



回答2:

You should jQuery with the function

$(function(){ $("#NameImage").css('display','none')})

But you should use the function of jQuery v1.7.3