473,748 Members | 8,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Small javascript/html that's not working as I think it should - please help

I have a small javascript/html code below that demonstrates that
problem I'm having in a larger program. I've tried all kinds of things
to get it to work, but it just won't do what I want. I've tried
setTimeout, setInterval. In this dumb, but valid example, i want to
display an iframe that loads google. Before it loads I want to display
a 'processing' indicator in green in the middle of the window. Then,
when it is done, it is to turn off the indicator. What is happening is
that in the doit() function, the processing(true ) statement doesn't
'appear' to run until after the iframe loads. Then it calls the
processing(fals e). So, the processing(true ) and processing(fals e)
'seem' like they are back to back and you never see the 'processing'
message. Simple question, referencing the doit() function, how do I
show the 'processing' div, load the iframe, then hide the 'processing'
div. In my larger app, I'm not using iframes, but I am doing some ajax
stuff that takes some computing time on the server and I want the user
to know that it's doing something.

here is the code
----------------------------------
<html>
<script>
function processing( p_flag )
{
var v_processingInd icator = document.getEle mentById( 'Processing'
);
if( p_flag ) {
if( ! v_processingInd icator ) {
v_processingInd icator = document.create Element( "div" );
v_processingInd icator.id = 'Processing';
v_processingInd icator.style.po sition = 'absolute';
v_processingInd icator.style.wi dth = '300px';
v_processingInd icator.style.le ft =
(document.body. clientWidth/2) - 150;
v_processingInd icator.style.to p =
(document.body. clientHeight/2);
v_processingInd icator.style.zI ndex = 10000;
v_processingInd icator.innerHTM L =
"<center>Proces sing...</center>";
v_processingInd icator.style.vi sibility = 'hidden';
v_processingInd icator.style.ba ckground = 'lightgreen';
document.body.a ppendChild( v_processingInd icator );
}

v_processingInd icator.style.vi sibility = 'visible';
} else {
v_processingInd icator.style.vi sibility = 'hidden';
}
}

function doit()
{
processing( true );
document.getEle mentById( 'iframe' ).src = 'http://www.google.com' ;
processing( false );
}
</script>

<body>
<iframe id='iframe' width='600' height='200'></iframe>
</body>

<script>doit(); </script>

</html>

-------------------------------
thanks in advance,
gkelly

Oct 26 '06 #1
1 1280
gk********@gmai l.com wrote:
I have a small javascript/html code below that demonstrates that
problem I'm having in a larger program. I've tried all kinds of things
to get it to work, but it just won't do what I want. I've tried
setTimeout, setInterval. In this dumb, but valid example, i want to
display an iframe that loads google. Before it loads I want to display
a 'processing' indicator in green in the middle of the window. Then,
when it is done, it is to turn off the indicator. What is happening is
that in the doit() function, the processing(true ) statement doesn't
'appear' to run until after the iframe loads.
Because most browsers will wait for the script to complete before
updating the screen, which is a good idea if you consider what it might
look like if you were doing lots of DOM manipluation in a script or
series of scripts.

Have your doIt() function use setTimeout() to call a function that
loads the page into the iFrame and attaches an onload function in the
iFrame that updates the "processing " mesage, e.g.:

function doit()
{
processing( true );
setTimeout(func tion(){
var iFrame = document.getEle mentById( 'iframe' )
iFrame.src = 'http://www.google.com' ;
iFrame.onload = function(){proc essing(false);}
},10);
}
--
Rob

Oct 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.