Questions › iframe design changing back to old design on page reload

I styled an external iframe here by following answer here. Everything is good but when I sort the table data or search within that iframe, the page reloads but old design comes up. Why is that?
I am using this code to fetch data from external resource


$content = file_get_contents('');
$content = str_replace('</title>','</title><base href="" />', $content);
$content = str_replace('</body>','<link rel="stylesheet" href="" type="text/stylesheet" /></body>', $content);
$content = str_replace('</head>','<link rel="stylesheet" href="" type="text/stylesheet" /></head>', $content);
echo $content;


and this is my iframe code

                echo '<iframe id="iframe" src="" name="Stack" height="1200" frameborder="0" scrolling="auto" width="100%"></iframe>';?>
Comments :

because when you submit the form it goes to rather than your script, you need to proxy all requests

Adam nick replied

@MichailStrokin any hint how to proxy, i am not too expert. I just dont want my entire work to be wasted. Thanks

charlietfl replied

Does the form submit by ajax on other site , or through default browser form submit? You definietly need a proxy for the links so that each link points to your server to get a new version pulled from external site to be rendered

Adam nick replied

@charlietfl no its simple request, no ajax

I'll add a new answer now

2 Answers :
Michail Strokin answered

the form uses $_GET variables, so you might do something like

$content = file_get_contents(''.http_build_query($_GET));

so that all variables passed to the form are appended to the fetched URL

Add this so that form submits to your server instead:

$content = str_replace('<form name="searchForm" action="index.php" enctype="multipart/form-data"  method="get">','<form name="searchForm" action="" enctype="multipart/form-data"  method="get">', $content);

update your CSS so that it doesn't rely on form[action=index.php]

update: Add this so that links are rewritten:

$content = str_replace("location.href='index.php?","location.href='", $content);

one more replace:

str_replace('<div class="sc-button-reset"><a href="index.php','<div class="sc-button-reset"><a href="', $content);
Michail Strokin replied
I've updated the answer;
Michail Strokin replied
added another update :);
Michail Strokin replied
Sorry, mistyped that URL again :) you need to use your own URL ( rather than exhibition-directory :);
Michail Strokin replied
use something like form[name='searchForm'] instead of form[action='index.php'] in your css as well so that it still looks good;
Michail Strokin replied
it does work as expected, just update the CSS so that it looks good;
charlietfl answered

Within the pages you scrape and return in iframe add click handlers to all the links that require reload.

Using jQuery

        var otherSiteHref = encodeURIComponent(this.href);
        var yoursSiteProxyUrl ='/path/to-your-php?url=' + otherSiteHref ;
        this.href = yoursSiteProxyUrl ;

Then at server decode the $_GET['url], get the new html from remote site and deliver it.

For the form, set up a controller method in your php and change the action to point to your proxy

$('#searchForm').attr('action', '/your-search-proxy.php');

You will need to make a cURL request to other site for the search form.

Michail Strokin replied
this might be a better approach but it won't work without JS;
charlietfl replied
@MichailStrokin of course it needs js....but so does 99.9 % of the web any more.;