Page 1 of 1

Detect failed URL in revBrowser

Posted: Sun Mar 17, 2013 1:45 pm
by doobox
Hi there,

I notice that the sample browser stack is not handling an invalid url either, so this may not be possible.

So here's the scenario:

A user enters an invalid url in my url field, and clicks go....
My loadNewUrl handler runs the "revBrowserNavigate tBrowserId, tUrl" function, but returns empty regardless of success or fail.
I get the browserBeforeNavigate message, where i could do something.. maybe..

Has anyone sussed how to detect a bad url when running "revBrowserNavigate tBrowserId, tUrl"..?

Re: Detect failed URL in revBrowser

Posted: Sun Mar 17, 2013 2:13 pm
by doobox
The only way i can currently see of doing this is below. But i don't like it.
If anyone can see a way to improve this, i'm all ears :-)

Code: Select all

global gUrlCheck

Code: Select all

on browserBeforeNavigate pInstanceId, pUrl
   put pUrl into field "url" of group gCurrentDevice
   put true into gUrlCheck
   send checkSuccess to this card in 6 seconds
end browserBeforeNavigate

Code: Select all

on checkSuccess
   if gUrlCheck then
      // its a bad url as the following handler has not switched the check var to false in six seconds
      answer "invalid url" with "OK" // do what i need to here
   end if
end checkSuccess

Code: Select all

on browserNavigateComplete pInstanceId, pUrl
   put false into gUrlCheck
end browserNavigateComplete