javascript - display an image while a page is loading in an iframe - Stack Overflow

I have a website with a menu, when menu item is clicked I display the page for that menu in an iframe(i

I have a website with a menu, when menu item is clicked I display the page for that menu in an iframe(iframe is set to display home page initially by default). sometimes it could take few seconds to display the page for the selected menu item (for example reports) and I would like to display a loading image while the page is loading. how to do this using javascript or jQuery (sample code will be helpful)? thanks in advance.

I have a website with a menu, when menu item is clicked I display the page for that menu in an iframe(iframe is set to display home page initially by default). sometimes it could take few seconds to display the page for the selected menu item (for example reports) and I would like to display a loading image while the page is loading. how to do this using javascript or jQuery (sample code will be helpful)? thanks in advance.

Share Improve this question edited Nov 26, 2010 at 12:44 RKP asked Nov 26, 2010 at 12:32 RKPRKP 5,39523 gold badges73 silver badges113 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Add the loading image to the iframe innerHTML ( or to a div and stop using iframe ) , then use ajax to fetch the new page content , on success iframe innerHTML bees the content fetched by ajax witch overwrites the loading image . easy to setup but i reend you stop using iframes

Usually you cannot know when the page finished loading in an iframe. The iframe loading is independent. What you can do is to get the content of the page that you have in the iframe through a ajax get request, and in this way do an animation while you wait for the content.

write a function to show the image and call it when you set the iframe src. when the page is loaded call from within the loaded page a function to hide the image (parent.HideImage) I think the onload event of the iframe is not supported in all browsers

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745246213a4618423.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信