Interact or communicate between 2 webgadgets

Share your advanced PureBasic knowledge/code with the community.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Interact or communicate between 2 webgadgets

Post by ricardo »

You can communicate or interact with 2 webgadgets (or even between a webgadget and iexplorer) in a very simple way.
Maybe this trick is not new for everybody, but i put it here to show how simple it is for the people that could find it usefull.

Code: Select all

xHtml$ + "<script>window.name='abc'</script>" ;Gives the webgadget some name

;Code for the other webgadget
xHtml1$ = "<a href='http://www.google.com' target='abc'>Direct the other webgadget to Google</a> <br> "
xHtml1$ + "<a href='http://www.purebasic.com' target='abc'>Direct the other webgadget to PureBasic site</a> <br> "
xHtml1$ + "<a href='http://www.yahoo.com' target='abc'>Direct the other webgadget to Yahoo</a> <br> "

If OpenWindow(0,100,50,600,600,"Communicate 2 webgadgets",#PB_Window_SystemMenu)
  CreateGadgetList(WindowID(0))
  WebGadget(0,0,0,600,300,"about:" + xHtml$)
  WebGadget(1,0,305,600,295,"about:" + xHtml1$)
  Repeat
    EventID=WaitWindowEvent()
    
    Select EventID
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 2
            
        EndSelect
        
    EndSelect
    
  Until EventID=#PB_Event_CloseWindow
EndIf