WebGadget problem with redirected site

Just starting out? Need help? Post your questions and find answers here.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

WebGadget problem with redirected site

Post 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
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: WebGadget problem with redirected site

Post by Rook Zimbabwe »

set a timer and stop when timeout! :mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Derren
Enthusiast
Enthusiast
Posts: 316
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: WebGadget problem with redirected site

Post by Derren »

Why are you setting the button on top of the webgadget?
If you don't overlap the gadgets it works fine.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: WebGadget problem with redirected site

Post by MachineCode »

I removed the overlapped button and now I can click it, but how can I stop the WebGadget from constantly refreshing?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: WebGadget problem with redirected site

Post 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?
Post Reply