Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load the page inside of IFRAME using ajax

how about loading your page using IFRAME ? I was thinking if this is possible ..

Example, i have this iframe below.

<iframe id="iframe" width="1024" height="600" src="http://www.sample.com"></iframe>

I want the www.sample.com page to load inside this iframe by not simply add the URL into src attribute, instead I'll get the current page data using ajax and to load using IFRAME tag. I'm thinking about this because I have a big problem on IFRAME cache most of the time.

I also try this thing but, it does not work perfectly on my end.

<iframe id="iframe" width="1024" height="600" src="http://www.sample.com?random=1422841682605""></iframe>

random is change everytime i load this iframe.

I want to apply it on my responsive tool like on the image below. If you need an actual view click here.

enter image description here

Thanks guys if have some idea out there .

like image 428
Anthony Carbon Avatar asked Feb 02 '15 01:02

Anthony Carbon


1 Answers

You can still use src but supply data URL like this:

src = 'data:text/html;charset=utf-8,' + 
    encodeURIComponent( // Escape for URL formatting
        '<!DOCTYPE html>'+
        '<html lang="en">'+
        '<body><h1>Another document!</h1></body>'+
        '</html>'
    );
like image 52
c-smile Avatar answered Sep 24 '22 03:09

c-smile