473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Way of halting execution until certain event completes

Mike Kypriotis
I have a loop where Itest if each of a set of images exists and if so display it the function for it is
Expand|Select|Wrap|Line Numbers
  1. function checkImgs()
  2. {
  3.     if (document.images)
  4.     {    
  5.           var imgsrc = 'Lo.jpg';
  6.           var img = new Image();
  7.  
  8.         img.onerror = function () {
  9.           alert(this.width + ',' + this.height + " can't be loaded.");
  10.           }
  11.         img.onload = function () {
  12.           alert(this.width + ',' + this.height + " is loaded.");
  13.           }
  14.  
  15.         img.src = imgsrc;
  16.     }
  17. }
  18.  
the plan is to set a variable inside the onload event and after calling checkImgs() to simply check that variable, problem is that program execution will not halt so almost always the script will proceed to checking the variable before the onload event fires and modifies it. And I cannot put my entire code to the onload event.Thought about putting the variable checking into a while where it won't exit while the variable is 0 (the events will either give it say a value of 1 or 2)but it is a good practice?
May 9 '11 #1
1 2216
decided to put everything in those two events... another question is is it 100% sure that one of the two events will be fired, cause if not my script will come to an unexpected halt (omitting the onabort which is a user action and thus if the user wants to stop loading/execution of the page nothing will happen)
May 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Matt | last post by:
Are there any settings to make a page invisible to the user until certain time? For example, I want mypage.html is invisible to the user until 12:00am. But mypage.html is already in the IIS server....
4
by: Dave H | last post by:
I originally posted a message "Getting the current cursor position using clientX,clientY" in which I hypothesised that the problem I was having was related to event handler execution order. I am...
2
by: Don | last post by:
Is there a way to halt execution of JavaScript? Looked in my reference and can't find anything on it. Thanks for your help, Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure...
1
by: john bailo | last post by:
Suppose I am writing a program that has to execute as series of steps, but at several of the steps, I want to wait for external events to occur. For example ( and this relates to another of my...
1
by: Jack Wright | last post by:
Dear All, I have observed that if I call a synchronous WebService from my aspx page then even if I set oProxy.TimeOut = 1000, the WebService thread execution is still running... Since my...
2
by: whornak | last post by:
The only way that I found to display a message to the user from an application that has an interface is by using the MessageBox.Show() method. What I need to do is notify the user of something...
1
by: Matthew Brown | last post by:
Hi, I am working with a COM library in which modifying almost every object is done asynchronously (because the object represent physical devices across a network somewhere on a telephone...
5
by: JoseValencia | last post by:
I have a page where I initialize a textbox.text value in the page_load event .. I have also a button where I want to do something with the value of the textbox.text . The user can change manually...
4
by: Spectre1337 | last post by:
Hello, I'm having huge difficulties solving what should be a relatively trivial problem. The following is a gross simplification (obviously it's not that simple in reality) but it will serve its...
3
by: Leo Smith | last post by:
Quick question and I am sure I just can't find the answer here. Is there a way to make an Asynch request from a browser without having to use an event? The only way I have found in ASP.NET is to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.