none
Catch webPage Link-click Address, how to ? RRS feed

  • Question

  • Hello & Thanks ;

    LDControls.BrowserSetURL(browser, url) :

    When I click on a webPage link , is there a command to catch that address as soon as possible .  Ie. , How soon can I catch it , because I want to check the link against a list of safeSites . 'Controls' or 'LD' or 'FC' or whatever ? 

    Thanks for your Hep...


    "All things in moderation, except for love and forgiveness."...vm

    Wednesday, August 12, 2020 1:58 PM

Answers

  • The first errormessage is now   row=91, col=1  EndSub not right on this place. This is because the fist line of the sub before line 63 in missing. That is also the subroutine where the compiler complains about.

    If you insert this line again, the program starts (I have done no more tests)


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Wednesday, August 19, 2020 11:03 AM typo
    • Marked as answer by vmars316 Wednesday, August 19, 2020 1:17 PM
    Wednesday, August 19, 2020 11:03 AM
    Answerer

All replies

  • Hi vmars316, I think there is no way...

    Nonki Takahashi

    Sunday, August 16, 2020 4:15 AM
    Moderator
  • Thanks '

    Once the page is loaded , 

    can I get the URL address that was loaded ? 

    Thanks


    "All things in moderation, except for love and forgiveness."...vm

    Sunday, August 16, 2020 9:21 AM
  • Perhaps use LDControls.BrowserHistory to get the history and the most recent is the current probably, then unload or revert or maybe use LDControls.BrowserNavigate.

    Sunday, August 16, 2020 6:34 PM
    Moderator
  • Thanks ;

    Ok , I'll give it a shot  : )

    Long term I am hoping to parse current loaded .html and change the "target = blank" to " " , for all links , and then check Links against  SafeSitesList . Do yous think it is possible ? 

    Something like this : https://www.youtube.com/watch?v=9EJXzWasTq4 

    Thanks 


    "All things in moderation, except for love and forgiveness."...vm

    Sunday, August 16, 2020 7:12 PM
  • Not sure exactly what you want, but the basic options for WebBrowser in LitDev extension should go a reasonable way with some imagination.  Type 'LDControls.Browser' to see the available commands.

    Of course you could do it in VB.Net or C# and get access to the full WebBrowser API - the SB extension just uses the .Net API (with reduced, but hopefully sufficient functionality to do some basic programming).

    So my advice is to understand the LDControls.Browser methods and get sufficiently confident with SB programming to see if it will meet your needs.  Even if it turns out in the the end that it doesn't, the time spent will not be wasted and will speed your programming jouney beyond SB where it is certainly possible to do what you want.

    Sunday, August 16, 2020 10:26 PM
    Moderator
  • Thanks ;

    -

    Perhaps use LDControls.BrowserHistory to get the history and the most recent is the current probably, then unload or revert or maybe use LDControls.BrowserNavigate.

    _

    Where would I even begin to code that ? 

    sub onBrowserPageLoaded
            GraphicsWindow.ShowMessage("BrowserPageLoaded" , "BrowserPageLoaded") 
    endsub   
    

    Thanks


    "All things in moderation, except for love and forgiveness."...vm

    Monday, August 17, 2020 2:53 AM
  • Thanks ;

    Yes , I'll keep hacking away at it .


    "All things in moderation, except for love and forgiveness."...vm

    Monday, August 17, 2020 2:55 AM
  • Hi LitDev ; 

    _
    Perhaps use LDControls.BrowserHistory to get the history and the most recent is the current probably, then unload or revert or maybe use LDControls.BrowserNavigate.
    _

    Where would I even begin to code that ? 

    sub onBrowserPageLoaded
            GraphicsWindow.ShowMessage("BrowserPageLoaded" , "BrowserPageLoaded") 
    endsub   
    Thanks

    "All things in moderation, except for love and forgiveness."...vm

    Monday, August 17, 2020 4:41 PM
  • Maybe start from this idea

    startURL = "https://duckduckgo.com/"
    browser = LDControls.AddBrowser(600,600,startURL)
    LDControls.BrowserPageLoaded = OnBrowserPageLoaded
    
    While ("True")
      Program.Delay(20)
    EndWhile
    
    Sub OnBrowserPageLoaded
      url = LDControls.LastBrowserPage
      GraphicsWindow.Title = url
      If (Text.GetIndexOf(url,"https") = 1) Then
        'OK
      Else
        'Revert to start
        LDControls.BrowserSetURL(browser,url)
      EndIf
    EndSub

    Monday, August 17, 2020 5:02 PM
    Moderator
  • Thanks LitDev ;

    I put the code above as the last Sub in the program .

    Turns out I get a "cannot find object LDControls" error , 

    On  LDControls.BrowserSetURL(browser,url) 

    So  moved it up a bit .

    Then I get the same error on any LD statement in the last Sub in the program . 

    If I remove Sub OnBrowserPageLoaded , all works fine . 

    I suspect this guy: LDControls.LastBrowserPage . 

    What are your thoughts ?

    Thanks 


    "All things in moderation, except for love and forgiveness."...vm

    Monday, August 17, 2020 8:30 PM
  • First - does the code I posted work on its own.  If it does then there is no reason to suspect that the compiler cannot find commands.

    Then check that you have put the code in correctly in your program - its not just a copy/paste - the code was to show how to consider doing what you want, not a finished example.

    If you cannot debug, then publish the code and post the ID.

    Tuesday, August 18, 2020 10:31 AM
    Moderator
  • Thanks LitDev ;

    * Posted OnBrowserPageUploaded program , on 'Publish' ID = JKM197-0 

    How does Publish work , is it like a forum ? will people respond to it ? Can I answer Posts ? 

    Thanks

    ' LDControls-Btn-TxtBox-Browser-VM-BrowserHistory.sb    One Window One Button One TextBox
    ' https://social.technet.microsoft.com/wiki/contents/articles/23583.small-basic-reference-documentation.aspx
    ' https://social.msdn.microsoft.com/Forums/en-US/home?forum=smallbasic
    ' Perhaps use LDControls.BrowserHistory to get the history and the most recent is the current probably,
    ' then unload or revert or maybe use LDControls.BrowserNavigate.
    ' to end program use  Program.End()
    
    firstTimeButtonClicked = 1
    htmlText = "Nuttin' in here yet !"
    browserWidth = 1000
    browserHeight = 500
    backButtonWidth = 75
    backButtonHeight = 30
    homeButtonWidth = 75
    homeButtonHeight = 30
    goButtonWidth = 75
    goButtonHeight = 30
    textBoxWidth = 300
    textBoxHeight = 300
    exitButtonWidth = 75
    exitButtonHeight = 30
    lastSiteVisited = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
    addressBarText = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
    url = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
    '===============================================================================
    browser = LDControls.AddBrowser(browserWidth , browserHeight , url)
    '===============================================================================
    Controls.SetSize(browser , 1000 ,500)
    Controls.Move(browser, 0, 50)
    
    Initialise()
    While ("True")
      Program.Delay(20)
    EndWhile
    
    Sub Initialise
      backButton = Controls.AddButton("<<-Back", 95, 8)
      Controls.SetSize(backButton,backButtonWidth , backButtonHeight)
      
      homeButton = Controls.AddButton("Home", 200, 8)
      Controls.SetSize(homeButton,homeButtonWidth , homeButtonHeight)
      
      goButton = Controls.AddButton("GO->>", 305, 8)
      Controls.SetSize(goButton,goButtonWidth , goButtonHeight)
      
      addressBar = Controls.AddTextBox(405,8)
      Controls.SetTextBoxText(addressBar , addressBarText)
      Controls.SetSize(addressBar , 200 ,30)  '  remove after testing
      
      htmlTextBox = Controls.AddMultiLineTextBox(630,4)
      Controls.ButtonClicked = OnButtonClicked
      
      exitButton = Controls.AddButton("Close", 855, 8)
      Controls.SetSize(exitButton,exitButtonWidth , exitButtonHeight)
      
      GraphicsWindow.Title="SafeBrowser"
      GraphicsWindow.CanResize="True"
      GraphicsWindow.Width = 1000
      GraphicsWindow.Height = 520
    EndSub ' Initialize
    
    Sub onBrowserPageLoaded
      GraphicsWindow.ShowMessage("BrowserPageLoaded" , "BrowserPageLoaded")
    EndSub
    
    
    Sub OnBrowserPageLoaded
      url = LDControls.LastBrowserPage
      GraphicsWindow.Title = url
      If (Text.GetIndexOf(url,"https") = 1) Then
        'OK
        GraphicsWindow.ShowMessage(url , "url = ")
      Else
        'Revert to start
        LDControls.BrowserSetURL(browser,url)
      EndIf
    EndSub
    
      If Controls.LastClickedButton = homeButton Then
        url = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
        If url <> "" Then
          LDControls.BrowserSetURL(browser, url)
        Else
          GraphicsWindow.ShowMessage(url , "url = ")
        EndIf
      EndIf '  homeButton
      
      If Controls.LastClickedButton = goButton Then
        url = Controls.GetTextBoxText(addressBar)
        If url <> "" Then
          LDControls.BrowserSetURL(browser, url)
        Else
          GraphicsWindow.ShowMessage(url , "AddressBar url = ")
        EndIf
        lastSiteVisited = url
      EndIf ' goButton
      
      If Controls.LastClickedButton = exitButton Then
        Program.End()
        
      EndIf '  exitButton
      
      htmlText = Network.GetWebPageContents(url)
      Controls.SetTextBoxText(htmlTextBox,htmlText)
      firstTimeButtonClicked = firstTimeButtonClicked  + 1
      
    EndSub ' OnButtonClicked 
    
    startURL = "https://duckduckgo.com/"
    browser = LDControls.AddBrowser(600,600,startURL)
    LDControls.BrowserPageLoaded = OnBrowserPageLoaded
    
    While ("True")
      Program.Delay(20)
    EndWhile
    
    Sub OnBrowserPageLoaded
      url = LDControls.LastBrowserPage
      GraphicsWindow.Title = url
      If (Text.GetIndexOf(url,"https") = 1) Then
        'OK
      Else
        'Revert to start
        LDControls.BrowserSetURL(browser,url)
      EndIf
    EndSub



    "All things in moderation, except for love and forgiveness."...vm

    Tuesday, August 18, 2020 1:49 PM
  • Thanks LitDev ;

    Yes , pgm works on its own .

    * Posted OnBrowserPageUploaded program , on 'Publish' ID = JKM197-0 

    How does Publish work , is it like a forum ? will people respond to it ? Can I answer Posts ? 

    Thanks 

    ' LDControls-Btn-TxtBox-Browser-VM-BrowserHistory.sb    One Window One Button One TextBox
    ' https://social.technet.microsoft.com/wiki/contents/articles/23583.small-basic-reference-documentation.aspx
    ' https://social.msdn.microsoft.com/Forums/en-US/home?forum=smallbasic
    ' Perhaps use LDControls.BrowserHistory to get the history and the most recent is the current probably,
    ' then unload or revert or maybe use LDControls.BrowserNavigate.
    ' to end program use  Program.End()
    
    firstTimeButtonClicked = 1
    htmlText = "Nuttin' in here yet !"
    browserWidth = 1000
    browserHeight = 500
    backButtonWidth = 75
    backButtonHeight = 30
    homeButtonWidth = 75
    homeButtonHeight = 30
    goButtonWidth = 75
    goButtonHeight = 30
    textBoxWidth = 300
    textBoxHeight = 300
    exitButtonWidth = 75
    exitButtonHeight = 30
    lastSiteVisited = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
    addressBarText = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
    url = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
    '===============================================================================
    browser = LDControls.AddBrowser(browserWidth , browserHeight , url)
    '===============================================================================
    Controls.SetSize(browser , 1000 ,500)
    Controls.Move(browser, 0, 50)
    
    Initialise()
    While ("True")
      Program.Delay(20)
    EndWhile
    
    Sub Initialise
      backButton = Controls.AddButton("<<-Back", 95, 8)
      Controls.SetSize(backButton,backButtonWidth , backButtonHeight)
      
      homeButton = Controls.AddButton("Home", 200, 8)
      Controls.SetSize(homeButton,homeButtonWidth , homeButtonHeight)
      
      goButton = Controls.AddButton("GO->>", 305, 8)
      Controls.SetSize(goButton,goButtonWidth , goButtonHeight)
      
      addressBar = Controls.AddTextBox(405,8)
      Controls.SetTextBoxText(addressBar , addressBarText)
      Controls.SetSize(addressBar , 200 ,30)  '  remove after testing
      
      htmlTextBox = Controls.AddMultiLineTextBox(630,4)
      Controls.ButtonClicked = OnButtonClicked
      
      exitButton = Controls.AddButton("Close", 855, 8)
      Controls.SetSize(exitButton,exitButtonWidth , exitButtonHeight)
      
      GraphicsWindow.Title="SafeBrowser"
      GraphicsWindow.CanResize="True"
      GraphicsWindow.Width = 1000
      GraphicsWindow.Height = 520
    EndSub ' Initialize
    
    Sub onBrowserPageLoaded
      GraphicsWindow.ShowMessage("BrowserPageLoaded" , "BrowserPageLoaded")
    EndSub
    
    
    Sub OnBrowserPageLoaded
      url = LDControls.LastBrowserPage
      GraphicsWindow.Title = url
      If (Text.GetIndexOf(url,"https") = 1) Then
        'OK
        GraphicsWindow.ShowMessage(url , "url = ")
      Else
        'Revert to start
        LDControls.BrowserSetURL(browser,url)
      EndIf
    EndSub
    
      If Controls.LastClickedButton = homeButton Then
        url = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
        If url <> "" Then
          LDControls.BrowserSetURL(browser, url)
        Else
          GraphicsWindow.ShowMessage(url , "url = ")
        EndIf
      EndIf '  homeButton
      
      If Controls.LastClickedButton = goButton Then
        url = Controls.GetTextBoxText(addressBar)
        If url <> "" Then
          LDControls.BrowserSetURL(browser, url)
        Else
          GraphicsWindow.ShowMessage(url , "AddressBar url = ")
        EndIf
        lastSiteVisited = url
      EndIf ' goButton
      
      If Controls.LastClickedButton = exitButton Then
        Program.End()
        
      EndIf '  exitButton
      
      htmlText = Network.GetWebPageContents(url)
      Controls.SetTextBoxText(htmlTextBox,htmlText)
      firstTimeButtonClicked = firstTimeButtonClicked  + 1
      
    EndSub ' OnButtonClicked 
    
    startURL = "https://duckduckgo.com/"
    browser = LDControls.AddBrowser(600,600,startURL)
    LDControls.BrowserPageLoaded = OnBrowserPageLoaded
    
    While ("True")
      Program.Delay(20)
    EndWhile
    
    Sub OnBrowserPageLoaded
      url = LDControls.LastBrowserPage
      GraphicsWindow.Title = url
      If (Text.GetIndexOf(url,"https") = 1) Then
        'OK
      Else
        'Revert to start
        LDControls.BrowserSetURL(browser,url)
      EndIf
    EndSub

    • Edited by vmars316 Tuesday, August 18, 2020 1:58 PM
    Tuesday, August 18, 2020 1:54 PM
  • The first errormessage is: There is another subroutune with the same name.

    You have to change one of the names (in the sub and the call).

    If you click "Publish" the active program is sent to the server and you get a name back consisting of three letters and three digits. If you give that name everybody can load that program through the "Import" button.

    Keep the structure of your program intact: Fisrt all lines of the main program and then all subroutines,

    Errormessages are very informative, you also have a wrong EndSub.


    Jan [ WhTurner ] The Netherlands


    Tuesday, August 18, 2020 5:20 PM
    Answerer
  • Thanks Jan [ WhTurner ] ;

    Ugh , Oops! Actually there were 3 Subs with the same name .

    I put out a new : 

    * JKM197-1 Publish OnBrowserPageLoaded  
    http://smallbasic.com/program/?JKM197-1 

    Even with the two subs removed , I still get the same error .

     Thanks


    "All things in moderation, except for love and forgiveness."...vm

    Tuesday, August 18, 2020 9:21 PM
  • The first errormessage is now   row=91, col=1  EndSub not right on this place. This is because the fist line of the sub before line 63 in missing. That is also the subroutine where the compiler complains about.

    If you insert this line again, the program starts (I have done no more tests)


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Wednesday, August 19, 2020 11:03 AM typo
    • Marked as answer by vmars316 Wednesday, August 19, 2020 1:17 PM
    Wednesday, August 19, 2020 11:03 AM
    Answerer
  • Thanks Jan ; 

    I must have deleted line recently .

    Thanks 


    "All things in moderation, except for love and forgiveness."...vm

    Wednesday, August 19, 2020 1:17 PM