html.loadurl problem

  1. 5 days ago

    Hi, I have a problem I can't figure out. (I'm on Xojo 2017 r3)
    I googled for this but can't find it.
    I have a listbox, populated with url's
    I do the following:
    get the index for the selected row, pass it to the listbox to get the content and load the selected url
    but it doesn't work

    dim theIndex as integer
    theIndex = listURL.ListIndex
    
    dim  theURL as string
    theURL = listURL.List(theIndex)
    
    msgbox(theURL)  '===> this shows the selected URL just fine
    
    HTML.LoadURL("https://mywebsitehere.com") '===> this does work
    HTML.LoadURL(theURL) '===> this however doesn't work

    does anyone have a clue what I'm doing wrong,

    OK, I'm sorry: I had marked the demofile as answer, but it was too soon. I saw it in action, and believed the "ToText" (inside the brackets, as opposed to the earlier answer with ToText outside the brackets) was the solution. I couldn't test it out though as I really needed to work on something else. Now that I have tested it, it isn't the solution ...
    However, the sample code did point me in the right direction.
    I saw the code from Tanner Lee, and he populated the listbox row with a literal string. And everything worked ...
    I didn't notice huge differences with my code, so I guessed the problem wasn't my code, but my variable string.
    I get the strings from reading each line in a textfile and adding them to the listbox as a row.
    Adding --- before and after the string showed me there was a line ending I wasn't aware of.
    In the shell I now trim the line ending with " tr -d '\n' " before passing it to listbox and all works fine ...
    So a big thanks for all the help, I really appreciate it. I just started with Xojo (after years of Applescripting everything), I'm totally excited, and it's great to see there is a nice community with friendly people who are willing to help each other out :-)

  2. Sascha S

    Nov 8 Pre-Release Testers, Xojo Pro Germany, Lower Saxonary
    Edited 5 days ago
    HTML.LoadURL( EncodeURLComponent( theURL ) ) '===> this sould work

    Source: http://docs.xojo.com/EncodeURLComponent

  3. Unfortunately that (EncodeURLComponent) does not work either ...

  4. Tanner L

    is not verified Nov 8 Pre-Release Testers Toronto, Canada
    Edited 5 days ago

    Try this. It works for me on 2019 R1.1.

    HTML.LoadURL(theURL).ToText

    Edit:

    Tested working on 2017 R3.

  5. Emile S

    Nov 8 Europe (France, Strasbourg)
    Edited 5 days ago

    Please, provide a real URL and then we will start to do a good job.

    Why ?

    Some URLs are relocated and will not work as is (error 301 if I recall correctly)

    Please, try this url: https://www.example.com/

  6. Derk J

    Nov 8 Pre-Release Testers, Xojo Pro
    dim theIndex as integer
    theIndex = listURL.ListIndex
    
    dim  theURL as string
    theURL = listURL.List(theIndex)
    
    msgbox(theURL)  '===> this shows the selected URL just fine
    
    HTML.LoadURL("https://mywebsitehere.com") '===> this does work
    HTML.LoadURL(theURL) '===> this however doesn't work

    you should do check if the ListIndex <> -1

    If no item is selected, ListIndex returns -1. If the ListBox is in multiple-row selection mode, then the number of the lowest selected row is returned. For example, if rows 1, 3, and 4 are selected, ListIndex returns 1.

    You can put the ListBox into multiple-row selection mode by changing the SelectionType property.

    see:
    http://docs.xojo.com/ListBox.ListIndex

    So try :

    dim theIndex as integer
    theIndex = listURL.ListIndex
    
    If theIndex = -1 Then 
    MsgBox "Please Select an item"
    return
    End If
    
    dim  theURL as string
    theURL = listURL.List(theIndex)
    
    msgbox(theURL)  '===> this shows the selected URL just fine
    
    HTML.LoadURL("https://mywebsitehere.com") '===> this does work
    HTML.LoadURL(theURL) '===> this however doesn't work
  7. The comment from Emile Schwarz defines the problem exactly ...
    example.com works perfectly ...
    on of my links is https://www.imagicasa.be/nl/stories and that doesn't work ...

    Then how do I get this to load ?

  8. Tanner L

    is not verified Nov 8 Pre-Release Testers Toronto, Canada

    Sample file here:

    https://cp.sync.com/dl/30032dd50/qt4zchq3-4h7resnj-xs2qptza-uprtwnwq

  9. Thank you SO much :-)

  10. Sascha S

    Nov 8 Pre-Release Testers, Xojo Pro Germany, Lower Saxonary

    @Tanner L Sample file here:

    https://cp.sync.com/dl/30032dd50/qt4zchq3-4h7resnj-xs2qptza-uprtwnwq

    Really? This is NOT the answer... Please tell us what went wrong and prevent others from running into the same issue. :)

  11. Rick A

    Nov 8 Pre-Release Testers (Brazil. GMT-3:00)
    Edited 5 days ago

    The pointed solution says that there is/was a bug with HTML.LoadURL( aStringValue ) but it works with HTML.LoadURL( aTextValue )

    So the proposed workaround was HTML.LoadURL( aString.ToText() )

  12. Sascha S

    Nov 8 Pre-Release Testers, Xojo Pro Germany, Lower Saxonary

    @Rick A The pointed solution says that there is/was a bug with HTML.LoadURL( aStringValue ) but it works with HTML.LoadURL( aTextValue )

    So the proposed workaround was HTML.LoadURL( aString.ToText() )

    Strange (because a String should work just fine). But thank you :)

  13. Derk J

    Nov 8 Pre-Release Testers, Xojo Pro

    @SaschaSchneppmueller Strange (because a String should work just fine). But thank you :)

    Try converting the encoding to UTF8

  14. OK, I'm sorry: I had marked the demofile as answer, but it was too soon. I saw it in action, and believed the "ToText" (inside the brackets, as opposed to the earlier answer with ToText outside the brackets) was the solution. I couldn't test it out though as I really needed to work on something else. Now that I have tested it, it isn't the solution ...
    However, the sample code did point me in the right direction.
    I saw the code from Tanner Lee, and he populated the listbox row with a literal string. And everything worked ...
    I didn't notice huge differences with my code, so I guessed the problem wasn't my code, but my variable string.
    I get the strings from reading each line in a textfile and adding them to the listbox as a row.
    Adding --- before and after the string showed me there was a line ending I wasn't aware of.
    In the shell I now trim the line ending with " tr -d '\n' " before passing it to listbox and all works fine ...
    So a big thanks for all the help, I really appreciate it. I just started with Xojo (after years of Applescripting everything), I'm totally excited, and it's great to see there is a nice community with friendly people who are willing to help each other out :-)

  15. Tanner L

    is not verified Nov 8 Pre-Release Testers Toronto, Canada

    @SaschaSchneppmueller Strange (because a String should work just fine).

    That's what I thought at first too. The debugger showed a simple UTF8 string without any gremlins. But the htmlviewer wouldn't open it. Added .ToText to the variable and it worked.

    In light of Chris' comment above I removed the .ToText call, and now it worked as documented.

    Chalking this up to a cache issue. Have 9 versions of RS/Xojo installed. :(

or Sign Up to reply!