Code: Select all
; This example does display the PureBasic.com website. Inside the callback procedure
; the navigation to the 'News' site will be avoided (#False returned), but allowed
; for all other sites (#True returned).
Procedure NavigationCallback(Gadget, Url$) ;Windows only
If Url$= "https://www.purebasic.com/news.php"
MessageRequester("", "No news today!") 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, "https://www.purebasic.com")
SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())
Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf
Fun fact, the menu with "News" for the PB homepage does not show on my computer windows 10 x64 pb 6.0 .
I guess because of Internet Explorer 11.
I changed the example to point to PB Support page and the callback to not allow Home page:
Code: Select all
; This example does display the Support page of the PureBasic.com website. Inside the callback procedure
; the navigation to the 'Home' site will be avoided (#False returned), but allowed
; for all other sites (#True returned).
Procedure NavigationCallback(Gadget, Url$) ;Windows only
If Url$= "https://www.purebasic.com/index.php"
MessageRequester("", "Can not go home today!")
ProcedureReturn #False
Else
ProcedureReturn #True
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 1310, 600, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 1290, 580, "https://www.purebasic.com/support.php")
SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Norm.