Tutorial :Content Loading



Question:

I am creating new Page with two divs.This Page Loading within Iframe.

First Div get contents from Database then load.Second Div contains Save and Cancel Button Only.

At the Time of loading Save and Cancel Button (Second Div) comes first.How to avoid this??


Solution:1

Hide the second div via CSS.

Then add some javascript which unhiddes the div when the loading from the DB is finished


Solution:2

Have the first document load the second document when it's ready. With a onload handler on the first document that sets the location of the second iframe.

Let's say your iframes have 2 ids: "iframe1" and "iframe2". You load the database content in iframe1, and an empty page in iframe2.

Here is a sample code for the document loaded in iframe1 :

<html>  <head>  <script>  function init () {     frameElement.ownerDocument.getElementById("iframe2").contentWindow.location = "/someurl/document2.html";  }  </script>  </head>  <body onload="init()">  <!-- iframe1 content -->  </body>  </html>  


Solution:3

Dynamically load the content using something like JQuery or Prototype to control when and how divs load.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »