I assume that by now, you’ve either figured it out, or have given up. But for the benefit of posterity, I’ll see if I can’t point you in the right direction! 
I do something somewhat similar, myself. (I had to, since Safari won’t cooperate with window.open() on file:// URLs.)
Besides my “normal” app windows, I have a couple of utility windows. One has a webview so that I can show web pages to the user at the appropriate times, and I’ve created 2 related to “load time”: loadingUserInfo and userInfoError. My main window is displayMain. None of them are set to be visible at launch.
The following will: display the “Loading” window, do the magic in the still-hidden webview, and display either the main interface or the error window when done. With some minor magic, you can keep the rest of your UI inaccessible until you display the main interface. (Indeed, I stripped out some of my app’s magic, and changed the window names slightly, for clarity!)
on launched theObject
tell window "loadingUserInfo"
set visible to true
end tell
if not my getLoginInfo() then
tell window "userInfoError"
set visible to true
end tell
set displayMain to false
else
set displayMain to true
end if
tell window "loadingUserInfo"
set visible to false
end tell
if displayMain then
tell window "Main"
set visible to true
end tell
end if
loadPage from "about:blank" into "htmlWindow"
end launched
on will close theObject
else if name of theObject is "userInfoError" then
quit
end if
end will close
on getLoginInfo()
loadPage from "http://www.mysite.com/profile?mode=login" into "htmlWindow"
set webView to view 1 of window "htmlWindow"
-- Without a delay, the checking of JS values seems to abort page load. Funk-ay!
delay 3
repeat with timer from 1 to 15
tell window "htmlWindow"
if (((call method "stringByEvaluatingJavaScriptFromString:" of webView with parameter ("document.readyState")) is "complete") and ((call method "stringByEvaluatingJavaScriptFromString:" of webView with parameter ("window.location")) is not "about:blank")) then
set userName to call method "stringByEvaluatingJavaScriptFromString:" of webView with parameter ("document.forms.profile.username.value")
set userID to call method "stringByEvaluatingJavaScriptFromString:" of webView with parameter ("document.forms.profile.user_id.value")
set SID to call method "stringByEvaluatingJavaScriptFromString:" of webView with parameter ("document.forms.profile.sid.value")
return true
else if timer ≥ 15 then
return false
else
delay 1
end if
end tell
end repeat
-- Better safe than sorry!
return false
end getLoginInfo
My only real complaint is that I like doing things by name, not number. And I don’t know the name of “view 1”. There’s a lot of stuff going on up there. If you need help with any of it, please do ask.
The major magic being done above is with checking whether the document’s loaded. That took quite a bit of reading and tinkering to get working right. (I refused to write any Objective C just to see if the document’s done!) Pretty much, it tries to load the page into the web view. Then, after the initial delay (2 worked fine for me, but I decided that 3 would be safer!), it starts a 15 second timer. It then uses JavaScript to ensure that the page has finished loading and that it’s not about:blank. (about:blank’s the default page when a webview is created.)
Once you have a loaded page, you can do whatever magic you need. I have all of my data in form fields to make life easier for processing.
Oh, and do be sure to wire up your script to the appropriate windows! :lol:
And, if you don’t actually have a webview in your project, you’ll probably start wondering how I load my pages into it (you can see loadPage above!). Again, I didn’t like the Objective C route.
I’ve included the original source of the code so that you can see the minor changes I have.
-- http://lists.apple.com/archives/Applescript-studio/2005/Apr/msg00142.html
on loadPage from theURL into windowName
set URLWithString to call method "URLWithString:" of class "NSURL" with parameter theURL
set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
tell window windowName
set mainFrame to call method "mainFrame" of object (view "htmlArea")
end tell
call method "loadRequest:" of the mainFrame with parameter requestWithURL
end loadPage