php - Javascript function returning just 1 value instead of an array of values -



php - Javascript function returning just 1 value instead of an array of values -

i trying find out page loading time using iframes. have array of urls, set array of iframes, , loadtime of each iframe using javascript. problem - time values not array, shows 1 value (it shows value of 1st frame sec later replaces value of 2nd frame on top of it).

<html> <body> <center> <?php $url = array('example.com', 'example2.com'); foreach($url $i){ ?> <iframe onload="pageloadingtime();" width="505" height="505" scrolling="no" security="restricted" src="<?php echo "http://www.".$i; ?> "></iframe> <?php } ?> <div id="loadingtime"></div> </center> </body> <script type="text/javascript"> beforeload = (new date()).gettime(); function pageloadingtime() { afterload = (new date()).gettime(); secondes = (afterload-beforeload)/1000; document.getelementbyid("loadingtime").innerhtml = "<font color='red'>(page took " + secondes + " seconds load)</font>"; } </script> </html>

in code create array of urls ($url), run foreach cycle making many iframes there urls, , using javascript count page loading time. after loading time set "loadingtime" div. said puts 1 value instead of putting array of values.

changed this, not displaying anything:

beforeload = (new date()).gettime(); function pageloadingtime() { var afterload = (new date()).gettime(); secondes = (afterload-beforeload)/1000; document.getelementbyid("loadingtime1").innerhtml += "<font color='red'>(page took " + secondes + " seconds load)</font><br>"; }

append status div instead of overwriting it:

document.getelementbyid("loadingtime").innerhtml += "<font color='red'>(page took " + secondes + " seconds load)</font><br>";

also, declare afterload , secondes local function:

var afterload = (new date()).gettime(); var secondes = (afterload-beforeload)/1000;

php javascript

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -