Wait until popup window finishes loading the execute javascript -
i have popup window displays multiple images, amount of images can change depending on user does. these images take 1.5 seconds each load can change depending on machines speed.
i need way wait popup finish loading images , execute script, what's best way of doing this?
edit:
popup.document.body.setattribute("onload","alert('hello');"); //wait popup finish loading popup.onload = function() { popup.alert("loaded"); }; none of above working...
edit 2 works diodeus. here code:
popup.document.write( '<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">'+ '<html><head>'+ '<script type="text/javascript">'+ 'var = '+doc('print_container2').getelementsbytagname('img').length+'; var c = 0;'+ 'function count_loaded() {'+ 'if (c == i) {'+ 'document.getelementbyid("print_container").style.display = "block";document.getelementbyid("loading").style.display = "none";'+ 'focus();print();close();'+ '}'+ '}'+ '</script>'+ ' <link rel="stylesheet" href="css/css.css">'+ '</head><body><h1 id="loading">loading... please wait...</h1>'+ '</body></html>' ); here images:
$hires .= "<img onload=\"c++;count_loaded();\" id=\"l".$key."_".$key2."_".$i."\" data-quantity=\"".$value2['quantity']."\" onclick=\"disable_print(this,'print_container')\" src=\"".$_session['root_dir']."php/generateimage.php?imgname=".$_session['root_path']."data/images/".$value2['location']."&restraint=".$restraint."\" class=\"\" />"; see onload event.
Comments
Post a Comment