Detect failed URL in revBrowser

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Detect failed URL in revBrowser

Post by doobox » Sun Mar 17, 2013 1:45 pm

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"..?
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Detect failed URL in revBrowser

Post by doobox » Sun Mar 17, 2013 2:13 pm

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
Kind Regards
Gary

https://www.doobox.co.uk

Post Reply