Page 1 of 1

WebGadget problem with redirected site

Posted: Tue Sep 06, 2011 3:00 pm
by MachineCode
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?

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

Re: WebGadget problem with redirected site

Posted: Tue Sep 06, 2011 4:55 pm
by Rook Zimbabwe
set a timer and stop when timeout! :mrgreen:

Re: WebGadget problem with redirected site

Posted: Tue Sep 06, 2011 5:20 pm
by Derren
Why are you setting the button on top of the webgadget?
If you don't overlap the gadgets it works fine.

Re: WebGadget problem with redirected site

Posted: Tue Sep 06, 2011 10:36 pm
by MachineCode
I removed the overlapped button and now I can click it, but how can I stop the WebGadget from constantly refreshing?

Re: WebGadget problem with redirected site

Posted: Thu Jan 19, 2012 10:54 am
by jesperbrannmark
I am using similar code a LOT and a lot of people get IMA on this line:

Code: Select all

      WebObject\get_Busy(@IsBusy.l)
Is there any way to prevent this? Can it be check before doing this? Like doing a isobject(webobject) or something?