Global variable browserCancel not work

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Global variable browserCancel not work

Post by ale870 » Thu Mar 04, 2010 6:09 pm

Hello,
I'm integrating revBrowser in my application, and I need to use the global variable browserCancel to avoi the user may navigate in unauthorized internet sites.
The problems is that variable does not work.
This is my code (I'm working on revBrowser example supplied by RunRev company self):

Code: Select all

on browserBeforeNavigate pId, pUrl
    global browserCancel
    put pUrl into message
    put true into browserCancel
end browserBeforeNavigate
The browser goes in the right page even if I set the variable "browserCancel" to true.

I'm working on Windows XP SP3 and Internet Explorer 6.

Please can you help me?

Thank you!
Runtime Revolution Widgets, tutorials, tips & tricks and more!
http://runrevwidgets.com/wiki

massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Re: Global variable browserCancel not work

Post by massung » Thu Mar 04, 2010 6:18 pm

ale870,

I have the exact same problem here on my machine (running the latest Mac OS X). I've posted this to the mailing list where others have claimed that it works for them. If you figure this out, I'd love to know how, because it's holding up one of my projects.

Jeff M.

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Re: Global variable browserCancel not work

Post by ale870 » Thu Mar 04, 2010 6:30 pm

Oh, I see.
I will make a check on Internet Explorer 7 or 8, just to test (I will make it tomorrow).

I will keep you updated!
Runtime Revolution Widgets, tutorials, tips & tricks and more!
http://runrevwidgets.com/wiki

massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Re: Global variable browserCancel not work

Post by massung » Fri Mar 05, 2010 8:24 am

Just thought I'd pass along a work-around that I thought of... works on OS X and I'll need to try Win32 tomorrow (I'm tired now). Assuming you are like me and generating the HTML for the browser to view, modify your <a> HREF's by putting a "#" in front of the URL. Then modify your message handler like so:

Code: Select all

on browserBeforeNavigate pBrowserID, pURL
   global browserCancel
   
   -- hack: invalid URLs on Safari get prefixed with applewebdata://...
   if the platform is "MacOS" then
      put char offset("#", pURL) to -1 of pURL into pURL
   end if
   
   -- launch our own browser instance
   if pURL begins with "mailto:" then
      revMail .....
   else
      -- strip the # sign off the URL
      launch URL char 2 to -1 of pURL
   end if
   
   -- don't actually navigate there in the browser
   put true into browserCancel
end browserBeforeNavigate
In Safari, if the browser gets a URL to an anchor on the page that doesn't exit it just won't even attempt to navigate to it. I don't know if IE will do the same or toss up some kind of error page.

If you don't generate your own HTML for the browser, but are actually browsing webpages, then I don't know, but I'll keep thinking for ya.

Jeff M.

Post Reply