Page 2 of 2

Re: [solved] How to read changed html code inside 'div contenteditable'

Posted: Fri May 17, 2024 11:51 am
by Derren
infratec wrote: Wed May 15, 2024 8:52 am @dige
No, you have a problem with html :wink:

รถ is:

Code: Select all

ö
in html
This shouldn't be an issue. It's not 2001 anymore. But the webpage should have the proper encoding tags.

Code: Select all

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8"> <!-- THIS -->
    </head>
    <body>
    </body>
</html>

As for the original question, I would normally use JS to manipulate and read anything from the DOM.
This code will give you the edited content of the entire document.
https://stackoverflow.com/questions/817 ... -a-string/


Presumably you really only want the contents of the div, in which case you should give it an ID and read the content like this.

Code: Select all

document.getElementById('test');

Here is a working example

Code: Select all

Procedure test(param$)
	Debug param$
EndProcedure 

  OpenWindow(0, 100, 100, 400, 400, "Hello", #PB_Window_SystemMenu)

  WebViewGadget(0, 0, 0, 400, 400)

  SetGadgetItemText(0, #PB_WebView_HtmlCode, ~"<div onclick=\"test(this.innerHTML)\" contenteditable>Hello World</div>\n")
  				

  BindWebViewCallback(0, "test", @test())

  Repeat 
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow