HTMLViewer 'textarea' text

  1. ‹ Older
  2. 2 years ago

    Tim P

    22 Mar 2017 Pre-Release Testers Rochester, NY

    I've been wrong once today so this could be 0 for 2, but I'm feeling confident in this one ;)

    The ChromiumFrameMBS is not the actual content of the page, but in reference to the view / scrolling ability of the HTML Viewer. It does not manipulate the page you have loaded up.

    I read elsewhere that you were at least able to successfully extract the HTML source of the page using MBS, you may have to extract the source and parse it to find the textarea and it's contents.

  3. Christian S

    22 Mar 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Answer Germany

    You should get html via our plugin.
    But you may prefer to run some javascript to get the textarea.
    e.g. "document.title = document.getElementByID('editor1').value"

  4. Christian S

    22 Mar 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    I don't see in Chromium API any call to execute javascript and getting result. Maybe due to the fact that it's asynchronously executed.

    And getting document title text is also not possible as far as I see.

  5. Michel B

    22 Mar 2017 Pre-Release Testers, Xojo Pro RubberViews.com

    The text of a TextArea is given by its HTML value
    https://www.w3schools.com/jsref/dom_obj_textarea.asp

    Christian already posted an example that will return the text.

    BUT lately, a pesky badly behaved extension has made an appearance for Chrome, which hides the content. See
    https://forum.xojo.com/39275-textarea-text-returns-undefined-when-using-grammarly-in-a-webap

    When that extension is used, value remains empty.

    I have been exchanging not so nice mail with them, as it seems not only do they mess up with HTML5 standard, but they would not hear of relations with other developers.

    From what I could see by exploring the DOM, they place the text within a DIV. But they also fill it with tags.

  6. David C

    23 Mar 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    Thanks to all. I tried transferring the JavaScript via document.status, but found that document.title works better since the Status is used for many other commands.

     Dim tempChromiumBrowserMBS As ChromiumBrowserMBS = myHTMLViewer.ChromiumBrowserMBS
      if tempChromiumBrowserMBS <> nil then
        tempChromiumBrowserMBS.ExecuteJavaScript(myCommand)
      end if
  7. David C

    23 Mar 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    Using document.title allows me about 4000 characters with the rest being truncated. Does anyone know how to successfully extract more?

  8. Tim P

    23 Mar 2017 Pre-Release Testers Rochester, NY

    @Tim P I read elsewhere that you were at least able to successfully extract the HTML source of the page using MBS, you may have to extract the source and parse it to find the textarea and it's contents.

  9. David C

    23 Mar 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    Thanks Tim. Yes I can extract the Source HTML on macOS using MainFrame.data, but this doesn't work for Windows and doesn't contain the text I type into my texture.

    When I use ChromiumFrameMBS.Source it gives me the surrounding HTML, but not the contents of this field (which also has HTML incidentally). Sometimes this subfield many have around 32K of text, but no images or files.

    I have a JavaScript routine that extracts the data I need, my only issue is where to put it so I can read it in Xojo.

  10. Tim P

    23 Mar 2017 Pre-Release Testers Rochester, NY
    Edited 2 years ago

    My point is not to use the Javascript hack because it doesn't work for you due to the limitations.
    For now it's probably best to use the plugins to get the whole page source, parse that to find the <textarea> you're looking for, and extract it's contents all in Xojo code.

    In other words, there is nowhere to put your Javascript routine because it will not work on Windows.

  11. Michel B

    23 Mar 2017 Pre-Release Testers, Xojo Pro RubberViews.com

    @David C I have a JavaScript routine that extracts the data I need, my only issue is where to put it so I can read it in Xojo.

    Since Return <value> cannot be used in Windows as the equivalent of EvaluateJavaScript does not return anything, it needs modification.

    It would be a lot easier if you posted the said routine, so I could post a modified one.

  12. Christian S

    23 Mar 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    For native renderer on windows I added textarea functions:

    method IESetTextAreaMBS(FormName as String, FieldName as String, Value as String) as Boolean

    method IEGetTextAreaMBS(FormName as String, FieldName as String) as String

    So I can put text in a hidden textarea and use that in my JavaScript. Result goes back through text area, too.

  13. David C

    24 Mar 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    @Tim P For now it's probably best to use the plugins to get the whole page source, parse that to find the <textarea> you're looking for, and extract it's contents all in Xojo code.

    In other words, there is nowhere to put your Javascript routine because it will not work on Windows.

    Tim, whenever I get the Source of the HTMLViewer it includes the structure of the textarea, but not the content of the textarea. I am happy to do the extraction with Xojo, but how have you manages to retrieve the source code with the textarea contents included?

  14. Tim P

    24 Mar 2017 Pre-Release Testers Rochester, NY

    Would you be able to paste what you get from ChromiumFrameMBS.Source at like Pastebin or something for me?

  15. David C

    24 Mar 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    Tim, here is the Source I can extract from CKEditor using the MBS for Windows tools. I have included the original HTML that it displays as well.

  16. Tim P

    24 Mar 2017 Pre-Release Testers Rochester, NY

    Okay, so it's giving you the source that was loaded, not the actual current state of affairs.
    Makes sense now as that's what you see when you go to View Source in your browser (navigating the DOM with developer tools is a different tool.)

    The only other thing I can recommend is to see if ChromiumFrameMBS.Text gives you anything useful.

    This weekend I'm updating HTML Edit to chunk up data and pass it out through TitleChanged, as there doesn't seem to be much of another solution even with plugins.

  17. Norman P

    24 Mar 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    @Tim P This weekend I'm updating HTML Edit to chunk up data and pass it out through TitleChanged, as there doesn't seem to be much of another solution even with plugins.

    Thats what Travis told you on the unsupported hacks thread
    The browser engines themselves dont give you a way to get at much - even with their SDK's

  18. Tim P

    24 Mar 2017 Pre-Release Testers Rochester, NY

    @Norman P Thats what Travis told you on the unsupported hacks thread
    The browser engines themselves dont give you a way to get at much - even with their SDK's

    I know, and I understand there's nothing Xojo can really do about it. That's why I have to change my implementation.

  19. Norman P

    24 Mar 2017 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    Or beat the vendors we rely on :)

  20. Christian S

    25 Mar 2017 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Tim, you are welcome to look into CEF source and let me know if you see something.

  21. David C

    27 Mar 2017 Pre-Release Testers, Xojo Pro Derby, ITM

    I have solved my original Windows JavaScript text extraction limitation by using a hidden iFrame (called TopFrame below) rather than a textarea or the title change event.

    First I use a ChromiumFrameMBS.MainFrame to place the desired HTML (any size) into the iFrame. Then I reused the ChromiumFrameMBS.Frame("TopFrame") to extract either the display text or the dumped Source HTML into Xojo. So far there is no 4096 character limit.

    Thank you to all who helped!

    Dim tempChromiumBrowserMBS As ChromiumBrowserMBS = myHTMLViewer.ChromiumBrowserMBS
    if tempChromiumBrowserMBS <> nil then
    Dim tempChromiumFrameMBS As ChromiumFrameMBS = tempChromiumBrowserMBS.MainFrame
    if tempChromiumFrameMBS <> nil then
    tempString = "TopFrame.contentWindow.document.open();" + EndOfLine
    tempString = tempString + "TopFrame.contentWindow.document.write(" + myCommand + ");" + EndOfLine
    tempString = tempString + "TopFrame.contentWindow.document.close();" + EndOfLine
    tempChromiumFrameMBS.ExecuteJavaScript(tempString)

    tempChromiumFrameMBS = tempChromiumBrowserMBS.Frame("TopFrame")
    if tempChromiumFrameMBS <> nil then
    Return tempChromiumFrameMBS.Source
    end if
    end if

or Sign Up to reply!