JavaScript - Wait Until Innerhtml Finish Rendered?
I try to get data from database and display them onto a div, after all messages are shown on the div, then only it will know the scrollheight of the div, it will auto scroll to the bottom of div as default by function asd(). My problem is when there are too many messages on database, it took very long time to display them all onto the div, so asd() executed before all messages are displayed. Meaning the scrollheight of the div is incorrect at this point, thus auto scroll to bottom is fail.
Code: $(function() { showMsg(); asd(); }); How to wait until showMsg() finish render the contents before execute asd()? I havejQuery.get(); .append(); .replace(); .innerHTML inside showMsg(). The problem is fixed when I use timeout to execute asd() after 3 seconds : Code: $(function() { showMsg(); setTimeout(asd();, 3000); }); That's why I sure asd() is executed when showMsg() is not yet finish loaded the contents. I guess I know where is the problem. If showMsg() is executed BEFORE the DOM is ready, and if asd() is executed AFTER DOM is ready (at this point all messages are rendered already), so the problem is fix. But now my situation is AFTER the DOM is ready, all messages still not yet finish rendered, because showMsg() and asd() are executed only AFTER the DOM is ready. "executed" doesn't mean "finish rendered". My question is how to make sure showMsg() finish rendered the contents into a div before execute asd() ? Similar TutorialsHey there guys, I'm working with an AJAX request that returns some stuff to print in 2 boxes. All working great, so I decided to make something fluffy, when I click a result in the AJAX request, he filters the clicked result, so you only see that clicked row. When clicked again, the old results will return. All working great. Now, my problem, I wanted a checkbox after every row in the search results and when the user clicks twice on a result to filter it and than goes back to the old results to check the checkboxes again that were checked before filtering that component. I made the functions and it didn't work till I put some alerts in, when the return function got some time to finish printing (like with the user had to click on OK in the alert) it worked. When I deleted the alerts, it didn't work again... I searched on the internet, found a function to wait for an image to load or smth similar and I found some guys that used a function to wait for a specific time (1 sec for example) and that's not what I want. If I use a specific waittime it can still fail if the PC is slow, or whatever, it's just not nice coding. So, is there something I can do so it waits till my AJAX request has been printed? Thanks! 'x. Hello, can make recommendations that it is necessary to finish in this site, I see that that that doesn't suffice but I will not understand that, to you I will be very grateful for your answers Here a site http://iceroos.ru I have some javascript <script type="text/javascript"> function loadGrid(x,y,z) { document.getElementById("feature").innerHTML='<br><center><b><font color=red face="times, times new roman, serif"><b></center>!Featured Products!</b><br></font><object width="600" height="600" type="text/html" data="./grid.php?offset='+x+'&feature='+y+'&category_id='+z+'" ></object>'; } </script> I just fill in a DIV with the contents of a php page in that code I write out a next previous buton print "<button onclick='loadgrid(1,1,%)'><img src=images/page_pics/".$p."></button><button onclick='loadgrid(1,21,%)'><img src=images/page_pics/".$n."></button>"; thats supposed to call the javascript above when clicked but it doesnt seem to work ...when the page is rendered into the DIV at client sould it be able to run the javascript above? <?PHP include('scripts/conf.php'); include('scripts/db_mysql.php'); $db_handle = mysql_connect(DB_HOST,DB_USERNAME,DB_PASSWORD); $db_found = mysql_select_db(DB_DATABASE, $db_handle); $ridx = 1; $cidx = 1; if ($db_found) { $SQL = "select * from tag_item where feature = ".$_GET["feature"]." and status = 1 and category_id like '".$_GET["category_id"]."' LIMIT 21 OFFSET " . $_GET["offset"] ; $result = mysql_query($SQL); $num_rows = mysql_num_rows($result); print "<table>"; while ( $db_field = mysql_fetch_assoc($result) ) { if ($cidx == 1 ) {print "<tr>";} print "<td width=90 style='border:solid 1px #000'>"; print "<center><img src='images/thumbs/" . $db_field["id"] . ".jpg'></center>"; print "</td>"; if($cidx == 3) {print "</tr>";} $cidx = $cidx + 1; if ($cidx == 4) { $cidx = 1; $ridx = $ridx + 1; } } print "</table>"; $p="prev.gif"; $n="next.gif"; if ($_GET["offset"] < 22) {$p="prevdis.gif";} if ($_GET["offset"] > $num_rows) {$n="nextdis.gif";} $newoffset = $_GET["offset"] + 21; print "<button onclick='loadgrid(1,1,%)'><img src=images/page_pics/".$p."></button><button onclick='loadgrid(1,21,%)'><img src=images/page_pics/".$n."></button>"; mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); } ?> hi I created a forloop and that runs fine, but it wont run any code after the loop finishes. I've tryed playing around with it but nothing I do will make it display the alert. Heres the problem code: Code: function price() { var price=0; for(var i=1; i<=15; i++) { if(document.form.partPrice[i].value == "price" == false) { price+=Number(document.form.partPrice[i].value); alert("test"); } } //wont run any code after here alert(price); } I'm not sure whats wrong, its probably something small that im overlooking but I just cant find whats wrong thanks in advance! Hi all, I've been trying to figure out for the past 4 hours why this JS pop up window function I wrote won't finish loading in Firefox. When you click the thumbnail image, it pops up a new window with the image enlarged. But for some reason, the Firefox page loading bar on the bottom right-hand side stops at about 25%, even after the image finishes loading. What is wrong with my code that I need to fix so the page shows that it loaded 100%? Here is a link to the page: http://www.unitedautoandtruck.com/cu...ilt_truck.html Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script language="javascript" type="text/javascript"> <!-- function pop_up_window (image, title, width, height, text, close_button, scroll_bars, bg) { var l = (screen.width-width) / 2 - 6; var t = (screen.height-height) / 2 - 28; var pop_up = window.open('', '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll_bars+',resizable=no,copyhistory=no,top='+t+',left='+l+',width='+width+',height='+height); pop_up.document.write ('<html>'); pop_up.document.write ('<title>'+title+'</title>'); window.name='main'; if (bg == 'default') bg = '#FFFFFF'; if (bg.charAt(0) == '#') pop_up.document.write ('<body bgcolor='+bg+' text=black link=blue vlink=purple alink=red>'); else pop_up.document.write ('<body background="'+bg+'" text=black link=blue vlink=purple alink=red>'); pop_up.document.write ('<style> A:link {text-decoration: none} A:visited {text-decoration: none} A:active {text-decoration: none} </style>'); if (image != ' ') { pop_up.document.write ('<center><img src="'+image+'"></center>'); } if (text != ' ') { pop_up.document.write ('<center><table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="94%"><tr><td>'); pop_up.document.write (''+text+''); pop_up.document.write ('</td></tr></table></center>'); } if (close_button == 1) { pop_up.document.write ('<form name="closeit">'); pop_up.document.write ('<center><input type="button" value="Close" onClick="window.close();"></center>'); pop_up.document.write ('</form>'); } pop_up.document.write ('</body>'); pop_up.document.write ('</html>'); } // --> </script> <title>Transformers Peterbilt Truck</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <a href="javascript:pop_up_window ('../images/customgallery/transformers_peterbilt_truck/DSC02061.jpg', 'Transformers', 623, 534, ' ', 1, 'no', 'default')" onMouseOver="window.status='Press to Enlarge'; return true"> <img src="../images/customgallery/transformers_peterbilt_truck/DSC02061.jpg" width="150" height="113"></a> </body> </html> Hi, I am having a Main homepage in my site which contains many pages rendered from different sources. And all these rendered pages are having a table like <table id="toc" class="toc"></table> . As all these are rendered in my homepage , those tables are appearing in my homepage.. I am trying to remove these tables from my homepage coding by javascript. So i tried with a onload option to remove it .. But i dono how to do this. Since by any way only one table in the first page rendered is removed and all others are having the table.. How can i do this?? Please help me.. Hey, I have a calculation system that uses ajax with php and xml and executes with onkeyup. The only problem with this is the result can be returned before the user finishes entering the entire number. My question is how can I give a delay prior to running the rest of the js. I know how to use setTimeout() but will it get reset out every time the function is called or for example if they enter 5 characters in the form, will the script be called 5 times with a second delay from each or will it only be called once? Is there a performance degradation involved? Hope that made sense. Thanks! ok. so i have all these big images and i need to let the whole page load before the viewer sees it what i would like is for a separate url (or something to completely cover the html page so you cant see it loading) to say please wait or something like that. Help! Hey all, So this has been stumping me for the past couple days and I am hoping someone can give me a clue on how this can be done. I have this function that is called when a next button is clicked: Code: function navigateToPage(pageurl){ audfile = null; pauseaudio(); jQuery("#coursecontent").attr("src", pageurl); jQuery("#coursecontent").load(function() { audfile = window.coursecontent.__backgroundaudio; }); //WAIT HERE UNTIL audfile IS NOT NULL playnextsound(); } My problem is that I have content loading in an iframe (coursecontent). I can't call playnextsound() until that content is loaded. I know that I could just put the playnextsound() in the load function but that won't work as I am trying to find a workaround for audio autoplay on the ipad. That is why I am setting the audfile in the load function. I need to wait until audfile is no longer null before calling playnextsound(). The problem is that I can't call playnextsound() from inside any timer or anything because it will cause autoplay audio to not work. I thought maybe a while loop would do the trick but that seems to just create an infinite loop. I would be forever grateful if someone could give me any pointers. Watching firebug on facebook, I noticed I'm able to receive chat messages and notifications without constantly polling the server. How is this achieved? Google gives me mixed (seemingly irrelevant) results. I read 3 different methods related to "reverse AJAX" but it doesn't seem to be exactly what I'm looking for - i.e., no constant polling and no "piggy-backing" (waiting for user to do something then send extra data).
This is my first post and hope someone can show me how to have JavaScript wait until a function has completed before moving on? I tried a timer, but the database does not always came back with data durning the time alloted. Thank you for any help. Code: function RunMerch() //Reprompt script { var fW = (typeof getFormWarpRequest == 'function' ? getFormWarpRequest() : document.forms['formWarpRequest']); if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );} //fW._oLstChoicesMyFieldName.selectedIndex = 0; var preFix = ''; if (fW.elements['cv.id']) { preFix = fW.elements['cv.id'].value; } setTimeout('oCV' + preFix + '.promptAction(\'reprompt\')', 1000); { //Call val () function -- This is where I want it to complete the reprompt function before moving on val(); } } // This will run the valtradselection() function function val() { valtradselection(); } I have an embedded font in my CSS however somtimes the texts loads before the font loads (i.e. the text is loaded in a normal font the it changes after). Is there anyway i can say dont load page until the font file is loaded, or maybe dont show the div until the font is loaded?
I have been using a javascript code to display a "Please wait..." message on screen but it seems to work in some instances and not in others. Please assist me with javascript code that works in all instances Issue 1:- it doesnt pops up with d wait msg ven v click on buttons.. the buttons are not submit buttons.. instead on clicking dat button it calls a fnformsubmit() userdfnd funtion.. Issue 2:-- even after d response cums the wait msg window doesnt close.. it hangs in d backgrnd.. The foll code is used in the footer.jsp file... Please assist... <html> <head> <script type="text/javascript" src="/js/os/jquery-1.5.1.min.js" ></script> <script type="text/javascript" src="/js/os/jquery-ui-1.8.14.custom.min.js"></script> <link rel="stylesheet" type="text/css" media="all" href="/js/os/jquery-ui-1.8.14.custom.css"> <script type="text/javascript"> for (var i = 0; i < document.links.length; i++) { var attrib = document.links[i]; if (attrib.addEventListener) { attrib.addEventListener('click', attachModalDialog, false); } else if (attrib.attachEvent) { attrib.attachEvent('onclick', attachModalDialog); } } function attachModalDialog(evt) { //alert('for Click event.'); $(ModalDialog).dialog({ modal: 'true', title: 'Please Wait...', width: 400, height: 300, closeOnEscape: false }).dialog('open'); return true; } </script> </head> <body> <div id="ModalDialog" style="display:none;"> <pre> Server side process is in-progress. Please wait..... </pre> </div> </body> </html> Hi, I have php script that uploads a file. once i click upload it should display a animated GIF image or "Loading please wait" message with the backround transparent screen covering the whole page so that the user is not able to click anything during file upload. How can i do this? Could someone help me on this. Thanks in advance. Hi, I have a site that runs a javascript slideshow automatically when a user visits it. It is designed in such a way that I cannot pre-load individual images for aesthetic reasons. (Also the whole concept makes my brain hurt.) I therefore need 1 of 2 things: 1. A preloader that doesn't show the page or start the slideshow until all the images are loaded. or 2. I could start with the slideshow paused, and when the page is fully loaded, the play command (currently attached to a 'play' button) is 'sent'. (I'm not techy, so this is the best I can do as explanation.) The latter would probably be more elegant, especially if ultimately I could hide the controls for the slideshow with a loading bar until all the html is loaded, and then show them when the slideshow starts. I'm sorry if this is a really basic question. I tried searching the site but couldn't find anything. If you do feel like answering, can you imagine that you are speaking to a 5 year old. Then dumb it down a bit. I need all the explanation and clarity I can get! Thanks! Hi all, Edit: Got it. I saved that source page and investigated closely and I realized that there's "Cookie plugin" script, which is not mentioned to add(?), in that tutorial I've been trying to implement the method given at http://dev.akabillposters.com/dom-js...-links-jquery/, but can't make it work. Nothing happens when I click the check box. I'm not a jquery expert, though tried some alerts statements to trace the issue, with no luck. Can anyone see what I'm missing? [link removed] Any help would be appreciated. Thanks. Hii...i have created a Gallery for my website..now i want to add a Please Wait gif image between every picture until it loads completely..So Please Help..where to and what to add..? HTML Part : Code: <div id="gellary"> <center> <form name=slideform> <table cellspacing=1 cellpadding=4 bgcolor="#4b7b9f"> <tr> <td align=center bgcolor="white"> <font style="color:#24618e"><b>Our Gallery</b></font> </td> </tr> <tr> <td align=center bgcolor="white" width=960 height=540> <img src="gallery/gall1.jpg" name="show" height="540" width="960"> </td> </tr> <tr> <td align=center bgcolor="#88d6f0"> <select name="slide" onChange="change();"> <option value="gallery/gall1.jpg" selected >Image 1 <option value="gallery/gall2.jpg" >Image 2 <option value="gallery/gall3.png">Image 3 <option value="gallery/gall4.png">Image 4 <option value="gallery/gall5.png">Image 5 <option value="gallery/gall6.jpg">Image 6 <option value="gallery/gall7.jpg">Image 7 <option value="gallery/gall8.jpg">Image 8 </select> </td> </tr> <tr> <td align=center bgcolor="#1797c4"> <input type=button onClick="first();" value="<< First" title="Beginning"> <input type=button onClick="previous();" value="<<" title="Previous"> <input type=button name="slidebutton" onClick="ap(this.value);" value="Start" title="AutoPlay"> <input type=button onClick="next();" value=">>" title="Next"> <input type=button onClick="last();" value="Last >>" title="End"> </td> </tr> </table> </form> </center> </div> =============================== JavaScript Part: Code: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var rotate_delay = 3000; // delay in milliseconds (5000 = 5 secs) current = 0; function next() { if (document.slideform.slide[current+1]) { document.images.show.src = document.slideform.slide[current+1].value; document.slideform.slide.selectedIndex = ++current; } else first(); } function previous() { if (current-1 >= 0) { document.images.show.src = document.slideform.slide[current-1].value; document.slideform.slide.selectedIndex = --current; } else last(); } function first() { current = 0; document.images.show.src = document.slideform.slide[0].value; document.slideform.slide.selectedIndex = 0; } function last() { current = document.slideform.slide.length-1; document.images.show.src = document.slideform.slide[current].value; document.slideform.slide.selectedIndex = current; } function ap(text) { document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop"; rotate(); } function change() { current = document.slideform.slide.selectedIndex; document.images.show.src = document.slideform.slide[current].value; } function rotate() { if (document.slideform.slidebutton.value == "Stop") { current = (current == document.slideform.slide.length-1) ? 0 : current+1; document.images.show.src = document.slideform.slide[current].value; document.slideform.slide.selectedIndex = current; window.setTimeout("rotate()", rotate_delay); } } // End --> </script> Hi, I'm having some issues turning this "Please Wait"/Disabled button into a function. Code: <input type="submit" value="Submit Form" onClick="this.disabled = 'true'; this.value='Please wait...';" /> Code: function pleasewait() { this.disabled = 'true'; this.value='Please wait..' } <input type="submit" value="Submit Form" onClick="pleasewait();" /> Thanks much Hello, I have been looking for a code which loads my content and images as well as my javascript and style before my visitor enters my site. I have been on a website before (I cannot remember the link) and it has: Quote: Please wait til we take our own sweet time to load this page with the content behind it, but slightly 'dimmed'. I think that this would be great for my site. If anyone would help me with this I will greatly appreciate it! Thanks. Hey, for some reason, this isn't working because of the src="images/edit.png" attribute. Here is my code: Code: <a href="#" onclick="change('HEYYY')"><img src="images/edit.png" alt="Edit" id="edit1" /></a> Javascript (External) Code: function change(message) { document.getElementById('edit1').innerHTML = '<input type="text" value="'+message+'" />'; } It does nothing. But if I take the src attribute out, it works fine. Any help? Thanks. |