HTMLViewer 'textarea' text

I have an HTML textarea (not Xojo TextArea) defines

<body> <form> <textarea name="editor1" id="editor1"></textarea> …
I need to extract the text within editor1. I can extract the Source from ChromiumBrowserMBS.MainFrame but the textarea contents is not amongst it.
Is this a frame? I tried to define a ChromiumFrameMBS for the texture (below), but it returns nil.

Dim tempChromiumFrameMBS As ChromiumFrameMBS = tempChromiumBrowserMBS.Frame("editor1")

I cannot find anything on the forums or MBS web site to help.

I’ve been wrong once today so this could be 0 for 2, but I’m feeling confident in this one :wink:

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.

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”

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.

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.

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

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

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.

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.

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.

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.

[quote=322379:@Tim Parnell]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.[/quote]
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?

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

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.

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.

[quote=322565:@Tim Parnell]
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.[/quote]
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

[quote=322572:@Norman Palardy]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[/quote]
I know, and I understand there’s nothing Xojo can really do about it. That’s why I have to change my implementation.

Or beat the vendors we rely on :slight_smile:

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