Update WebView with new HTML sent from TextArea
I am trying to make a simple HTML editor. I am trying to have the WebView display whatever HTML is typed into the TextArea. The HTML that is put into the TextArea prior to compiling displays in the WebView fine but after the program is running, when i change the text in the TextArea, it doesn't change the WebView HTML at all. I have tried to add a reload() event to the tab2 because I thought maybe the WebView just needed to be refreshed but it still doesn't work. This is my first serious attempt to write a program. Please help me.
My simple code can be seen on a Pastie here:
http://pastie.org/959575
1 Answer
-
Accepted Answer
Hey Justice,
There's no way to bind the webView.html with anything else in an app, so each time you want it to change you'll have to specify what the new value is.
One way to do that is to add an event listener to the tab so when you change to tab2 it will grab the value of ta1 and make that the new value of webView.html. Adding something like this to your code should get you going.
tab2.addEventListener('focus', function() { webView.html = ta1.value; });