WebGadget links open in default browser?
WebGadget links open in default browser?
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!
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: WebGadget links open in default browser?
You can add a WebGadget callback and check the links.
Look in the help for WebGadget and #PB_Web_NavigationCallback.
Look in the help for WebGadget and #PB_Web_NavigationCallback.
Re: WebGadget links open in default browser?
Wow, I can't believe it was that simple! Thanks!
For my future reference:
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