javascript - How to show loading gif while iframe is loading up a website? -


i have inc/content.php file contains iframe src= domain.

on index.php page have button <button id="nextbutton" onclick="viewnext();return false;">new</button> when clicked calls following javascript function:

<script type="text/javascript"> function viewnext() {   $('#content').load('inc/content.php'); } </script> 

function loads iframe inc/content.php file index.php page <div id="content"></div>

how can show loading.gif image while inc/content.php file gets loaded index file?

you can display loading image before loading page, , hide when done (use second parameter adding callback called when request has completed):

$("#loading").show(); $("#content").load("inc/content.php", function () {     $("#loading").hide(); }); 

obviously, need element in document id loading, like:

<img id="loading" src="loading.gif" alt="loading"> 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -