#READYSTATE_UNINITIALIZED = 0
#READYSTATE_LOADING = 1
#READYSTATE_LOADED = 2
#READYSTATE_INTERACTIVE = 3
#READYSTATE_COMPLETE = 4
If OpenWindow(0, 10, 10, 700, 500, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "WebGadget ReadyState") And CreateGadgetList(WindowID())
WebGadget(0, 10, 10, 680, 460, "http://www.purearea.net/pb/CodeArchiv/English.html")
;--> Expose the IWebBrowser2 object so we can catch the load state
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(0), #GWL_USERDATA) ; needed for accessing IWebBrowser interface
CreateStatusBar(0, WindowID())
StatusBarText(0, 0, "")
Repeat
event = WaitWindowEvent()
;--> If WebGadget is busy loading a page
If isBusy
WebObject\get_ReadyState(@isReady)
;--> Determine the load state
Select isReady
Case 1
StatusBarText(0, 0, "Page Loading")
Case 2
StatusBarText(0, 0, "Page Loaded")
Case 3
StatusBarText(0, 0, "Page is interactive with some data missing")
Case 4
StatusBarText(0, 0, "Page finished loading")
EndSelect
EndIf
;--> If page is loaded
If isReady > 1
webURL$ = GetGadgetText(0)
;--> and the url is not "http://www.purearea.net/pb/CodeArchiv/English.html"
If webURL$ <> "http://www.purearea.net/pb/CodeArchiv/English.html"
;--> Go back to "http://www.purearea.net/pb/CodeArchiv/English.html"
SetGadgetState(0, #PB_Web_Back)
MessageRequester("Info", webURL$ + " has been blocked")
EndIf
EndIf
;--> Get the load state of WebGadget
WebObject\get_busy(@isBusy)
Until event = #PB_Event_CloseWindow
EndIf
End