Merry Christmas guys,
I found a code that displays a loading message using a gif. It uses the onLoad=”init()” in the body tag. It works fine on an HTML file but it doesn’t when the file is in PHP. Do I need to change anything in here or this just won’t work in a PHP file? here’s the code:
<body onLoad="init()">
<div id="loading" style="position:absolute; width:100%; text-align:center; top:300px;">
<img src="loading.gif" border=0></div>
<script>
var ld=(document.all);
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
if (ns4)
ld=document.loading;
else if (ns6)
ld=document.getElementById("loading").style;
else if (ie4)
ld=document.all.loading.style;
function init() {
if(ns4){ld.visibility="hidden";}
else if (ns6||ie4) ld.display="none";
}
</script>
<?php
include('simple_html_dom.php');
$html= new simple_html_dom();
$html->load_file('urls.html');
$element = $html->find("p");
$size = count($element);
for($i=0; $i <= $size ;$i++){
printinfo($element[$i]->innertext);
}
function printinfo($url){
$page= new simple_html_dom();
$page->load_file($url);
$arr = $page->find("title");
echo $arr[0]->innertext." = ";
$arr = $page->find('.altroute-rcol');
echo $arr[0]->innertext."<br>";
}
?>
</body>
EDIT: What my php code does is parse some code and displays the info that I needed. The code works fine, depending on how many urls that I need to parse it could take up to 30 secs that’s why I needed a loading message.
Thanks in advance!!!
PHP responses don’t start loading until they’re finished processing. Where a browser will display an HTML page progressively, PHP pages are typically displayed all at once.
You can force a PHP response to display progressively by calling
flush()at the point you want to send a partial response, but support varies between servers.Try putting
flush();before you parse your XML and let us know if that helps.