How can I set up my vbs program to know when Firefox has loaded a web page completely?
I am using Firefox to load 开发者_如何学JAVAprogrammatically a webpage (I use a vbs file).
Dim objShell
Set objShell=CreateObject("WScript.Shell")
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):
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.
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.
精彩评论