Page 1 of 1
WebGadget links open in default browser?
Posted: Fri Nov 17, 2017 12:08 pm
by Dude
If I have a WebGadget in my app, can I make any clicked links open OUTSIDE of my app and in the PC's normal default browser instead? Sort of like the "target=_blank" meta-tag but for links that don't have that tag? I basically want to use the WebGadget to show an index page of links (that I didn't create, and hosted by someone else) but they open outside of my app. Thanks!
Re: WebGadget links open in default browser?
Posted: Fri Nov 17, 2017 1:06 pm
by RSBasic
You can add a WebGadget callback and check the links.
Look in the help for WebGadget and #PB_Web_NavigationCallback.
Re: WebGadget links open in default browser?
Posted: Fri Nov 17, 2017 1:15 pm
by Dude
Wow, I can't believe it was that simple!
Thanks!
For my future reference:
Code: Select all
Procedure NavigationCallback(Gadget, Url$)
If Url$= "http://www.purebasic.com/news.php"
RunProgram(Url$) ; Open in default browser.
ProcedureReturn #False
Else
ProcedureReturn #True
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")
SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf