views:

25

answers:

1

Hi All
I am using Firefox to load programmatically a webpage (I use a vbs file).
   1. Dim objShell
   2. Set objShell=CreateObject("WScript.Shell")
   3. objShell.Run "firefox.exe http://www.google.com/"
Then, I have set a time out to allow browser to load completely the web page before my program to continue with the next steps (a web page is expected to load in maximum 5 seconds):
   1. WScript.Sleep 5000
However, there are webpages that are loaded in 20-30 seconds.
In order to define an appropriate time for each user to expect the page to load, I need to know how can my program know when Firefox has loaded a web page completely.
Constraints: javscript is disabled for users (company policy) Of course, to cover all cases I could setup a 50 seconds time within the program, but I am afraid the user will become bored for pages that are loaded in 5 seconds and then the program does nothing for the next 45 seconds.

A: 

I don't believe there is a reasonable way for you to know when Firefox completed it's loading task from a visual basic script...or from almost any other execution environment. It's a separate process and the only way you could accomplish your goal is if the browser provided an API to query it's status, receive events etc.

If it's really important, you might try to write a browser extension which might be able to inform you when the page has been loaded.

Tomislav Nakic-Alfirevic
Now, it came to my mind something else: what about a way maybe to record the number of packets per unit time exchanged by the browser with the web server and if that indicator slows down to zero ... could exist some small script like that? If not, I guess I shall create it ... but am not sure about resonabless of this solution.