WebGadget problem with redirected site
Posted: Tue Sep 06, 2011 3:00 pm
Here's some old code I found in these forums to show the state of the WebGadget. What I noticed today, is that when a website is redirecting itself to itself, in a loop, the WebGadget can't be stopped. For example, currently the website www.demonoid.me has been hacked (I suspect) to reload itself over and over. So, the WebGadget below can't "finish".
Try this code to see what I mean. How can our app deal with such a self-reloading URL?
Try this code to see what I mean. How can our app deal with such a self-reloading URL?
Code: Select all
#READYSTATE_UNINITIALIZED=0
#READYSTATE_LOADING=1
#READYSTATE_LOADED=2
#READYSTATE_INTERACTIVE=3
#READYSTATE_COMPLETE=4
If OpenWindow(0,10,10,700,500,"WebGadget ReadyState",#PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
WebGadget(0,10,10,680,460,"http://www.demonoid.me")
ButtonGadget(1,10,10,680,50,"Try to click me when the page is loading")
;--> Expose the IWebBrowser2 object so we can catch the load state
WebObject.IWebBrowser2=GetWindowLongPtr_(GadgetID(0),#GWL_USERDATA) ; To access IWebBrowser interface.
CreateStatusBar(0,WindowID(0))
AddStatusBarField(650)
StatusBarText(0,0,"")
Repeat
event=WaitWindowEvent()
If event=#PB_Event_Gadget And EventGadget()=1
Debug "Button clicked"
EndIf
;--> 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)
EndIf
;--> Get the load state of WebGadget
WebObject\get_busy(@isBusy)
Until event=#PB_Event_CloseWindow
EndIf