 
 Unfortunately it chrashes every time I click one of the links in the sample code.
 
 I'm using XP Home/SP2, PB 3.93.



Num3 wrote: I seem to have some troubles...
This code doesn't work with mozilla firefox activeX
Freak wrote: i have posted a lot of code to interface with the Document Object Model of IE or the WebGadget.


Code: Select all
If Element\get_tagName(@bstr_tagName) = #S_OK
          length = WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, 0, 0, 0, 0)
          tagName$ = Space(length)
          WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, @tagName$, length, 0, 0)
          SysFreeString_(bstr_tagName)
          If (LCase(tagName$) <> "a")
            Element\get_parentElement(@Element.IHTMLElement)
            If Element\get_tagName(@bstr_tagName) = #S_OK
              length = WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, 0, 0, 0, 0)
              tagName$ = Space(length)
              WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, @tagName$, length, 0, 0)
              SysFreeString_(bstr_tagName)
            EndIf
          EndIf
        EndIf
 Also it implies that only the "a" tag leads to a external resource plus that the parent of any other tag actually is the "a" tag. Since this was done as "proof of concept" and works for the given site, it was good enough for me
 Also it implies that only the "a" tag leads to a external resource plus that the parent of any other tag actually is the "a" tag. Since this was done as "proof of concept" and works for the given site, it was good enough for me 


Code: Select all
          If (LCase(tagName$) <> "a")
            Element\get_parentElement(@Element.IHTMLElement)
            If Element\get_tagName(@bstr_tagName) = #S_OK
              length = WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, 0, 0, 0, 0)
              tagName$ = Space(length)
              WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, @tagName$, length, 0, 0)
              SysFreeString_(bstr_tagName)
            EndIf
          EndIfCode: Select all
          While (LCase(tagName$) <> "a")
           If Element\get_parentElement(@Element.IHTMLElement) = #S_OK
             If Element\get_tagName(@bstr_tagName) = #S_OK
               length = WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, 0, 0, 0, 0)
               tagName$ = Space(length)
               WideCharToMultiByte_(#CP_ACP, 0, bstr_tagName, -1, @tagName$, length, 0, 0)
               SysFreeString_(bstr_tagName)
             Else
              Break
             EndIf
           Else
            Break
           EndIf
          WendCode: Select all
Enumeration 1 
  #OLECMDID_OPEN 
  #OLECMDID_NEW 
  #OLECMDID_SAVE 
  #OLECMDID_SAVEAS 
  #OLECMDID_SAVECOPYAS 
  #OLECMDID_PRINT 
  #OLECMDID_PRINTPREVIEW 
  #OLECMDID_PAGESETUP 
  #OLECMDID_SPELL 
  #OLECMDID_PROPERTIES 
  #OLECMDID_CUT 
  #OLECMDID_COPY 
  #OLECMDID_PASTE 
  #OLECMDID_PASTESPECIAL 
  #OLECMDID_UNDO 
  #OLECMDID_REDO 
  #OLECMDID_SELECTALL 
  #OLECMDID_CLEARSELECTION 
  #OLECMDID_ZOOM 
  #OLECMDID_GETZOOMRANGE 
  #OLECMDID_UPDATECOMMANDS 
  #OLECMDID_REFRESH 
  #OLECMDID_STOP 
  #OLECMDID_HIDETOOLBARS 
  #OLECMDID_SETPROGRESSMAX 
  #OLECMDID_SETPROGRESSPOS 
  #OLECMDID_SETPROGRESSTEXT 
  #OLECMDID_SETTITLE 
  #OLECMDID_SETDOWNLOADSTATE 
  #OLECMDID_STOPDOWNLOAD 
EndEnumeration 
Enumeration 0 
  #OLECMDEXECOPT_DODEFAULT 
  #OLECMDEXECOPT_PROMPTUSER 
  #OLECMDEXECOPT_DONTPROMPTUSER 
  #OLECMDEXECOPT_SHOWHELP 
EndEnumeration 
;Note! Not all the constants above work as some require
;a VARIANT structure and a bit more to work properly.
;However, for "fire and forget" commands this procedure works great though!
Procedure WebGadget_Exec(Gadget,command,option)
 Browser.IWebBrowser2 = GetWindowLong_(GadgetID(Gadget), #GWL_USERDATA)
 If Browser
  If Browser\ExecWB(command, option, 0, 0) = #S_OK
   ProcedureReturn 1
  EndIf
 EndIf
ProcedureReturn 0
EndProcedure
Code: Select all
S=S+"<html><head><meta http-equiv='MSThemeCompatible' content='yes'></head>"+Lf
	 S=S+"<body scroll=auto link=blue vlink=blue alink=green>"+Lf 
   S=S+"<form method='post' action=submit>"+Lf+LfCode: Select all
->Shared<- WebGadget_Document.IHTMLDocument2_FIXEDCode: Select all
SetGadgetText(Window()\WebGadget,WebPath$+"Logs/"+Window()\FileName$)Code: Select all
  If WebGadget_Open(#WebGadget, 0)
    If PureFILE_ReadTextFile(#PB_Any, "page.html")
      While PureFILE_NotEof()
        WebGadget_Write(PureFILE_ReadString())
      Wend
      PureFILE_CloseFile()
    EndIf
    WebGadget_Close() 
  EndIf
  WebGadget_CatchLinks(#WebGadget, @LinkCallback())
Code: Select all
WebGadget(#WebGadget,20,20,400,300,"page.html")
WebGadget_CatchLinks(#WebGadget, @LinkCallback())
Can you give me an example?freak wrote:To use this with real files, you have to check with the WebGadget_IsLoaded() in a loop until it returns 1,
before you set the links callback.
Code: Select all
WebGadget(#WebGadget,20,20,400,300,"page.html")
Repeat
Until WebGadget_IsLoaded(#WebGadget)
WebGadget_CatchLinks(#WebGadget, @LinkCallback())