I was able to do only with jquery using a proxy, now just work with css and script to work tabs, but this I leave with you:
jquery:
$('#divframe').load(
'http://www.corsproxy.com/' +
'www.cptec.inpe.br/widget/widget.php?p=3819&w=h&c=474647&f=ffffff .tabtop', function() {
$('#divframe').html( $('#divframe').html().replace(new RegExp('src="', 'g'),'src="http://www.cptec.inpe.br/widget/') );
});
HTML:
<div id="divframe"></div>
jsfiddle: http://jsfiddle.net/jaderw/kuLdmnm4/
EDIT: jsfiddle with tabs script working: http://jsfiddle.net/jaderw/kuLdmnm4/2/
Alternative with own proxy in PHP:
proxy.php (with just that content, and nothing else)
<?php
$cache_file = 'proxy_cache.html'; // nome do arquivo para salvar cache
if (!@file_exists($cache_file) || (time() - @filemtime($cache_file) > (60 * 60 * 6))) { // verificar se o cache expirou e fazer uma nova requisição ao cptec.inpe.br
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.cptec.inpe.br/widget/widget.php?p=3819&w=h&c=474647&f=ffffff");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$retorno = str_replace('src="','src="http://www.cptec.inpe.br/widget/',curl_exec($ch)); // adicionar o endereço absoluto a todos os src
curl_close($ch);
file_put_contents($cache_file, $retorno); // salvar conteudo no arquivo de cache
} else { // cache não expirou abrir o conteudo do arquivo sem nova requisição ao cptec.inpe.br
$retorno = file_get_contents($cache_file);
}
echo $retorno; // imprimir o conteudo
?>
The content below should be in another file, together with css and
everything else... ex file: html test.
jquery:
$('#divframe').load(
'proxy.php .tabtop', function() {
$('#divframe .tab_content').hide();
$('#divframe .tabs li:first').addClass('active');
$('#divframe .tab_content:first').show();
$('#divframe .tabs li').click(function(){
$('#divframe .tabs li').removeClass('active');
$(this).addClass('active');
$('#divframe .tab_content').hide();
$($(this).children('a').attr('href')).show();
});
});
HTML:
<div id="divframe"></div>
iframe is in the same domain as your website?
– Sergio
I don’t know the security implications of CSS, but at first I’d say you can’t modify nothingness in the content of a
iframe
that does not belong to the same origin (schema, domain and maybe port) of your main page. The most you can do - if the browser supports - is to put theiframe
in a sandbox, blocking Ajax, Javascript, etc.(in this case, for home page to protect against embedded malicious content). But arbitrary modifications, I’m afraid, impossible, and with good reason.– mgibsonbr
@mgibsonbr, I removed the answer... I thought it was possible
– Papa Charlie
If you create a proxy type by loading the content using Curl, you could modify what you wanted before printing...
– Jader A. Wagner
See if this can help you http://stackoverflow.com/questions/217776/how-to-apply-css-to-iframe
– Samir Braga
No @Sergio is on an external website.
– Alexandre Lopes