# Get JavaScript variables back from HTMLViewer without changing the title.

**URL:** <https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378>\
**Category:** General\
**Created:** [May 20, 2015, 3:15pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378 "2015-05-20T15:15:21Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [August 24, 2018, 2:26pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/21 "2018-08-24T14:26:59Z")

</div>

There’s a way to do this on macOS with the WKWebView engine and the WKScriptMessageHandler but (A) I think Xojo is using the older WebView engine, and (B) this code is in Swift. Perhaps it could be adapted?  
[https://medium.com/@tonespy/communicating-between-angular-javascript-in-wkwebview-and-native-code-368e6941d7f5](https://medium.com/@tonespy/communicating-between-angular-javascript-in-wkwebview-and-native-code-368e6941d7f5)

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 24, 2018, 3:09pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/22 "2018-08-24T15:09:00Z")

</div>

We have that in MBS Plugins.

See [WKWebViewControlMBS](https://www.monkeybreadsoftware.net/control-wkwebviewcontrolmbs.shtml) control

---

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 24, 2018, 4:06pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/23 "2018-08-24T16:06:07Z")

</div>

> [@402411:@Tim Streater](#):
>
> Trouble with titlechanged is you are limited in the length returned. Statuschanged still works with default renderer in 2018r2 macOS, but the question is for how much longer.

Isn’t TitleChanges the only one cross-platform?

What’s updated from JavaScript with StatusChanged, that triggers the event?

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 24, 2018, 4:09pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/24 "2018-08-24T16:09:36Z")

</div>

Inside your HTMLViewer you do:

```auto
window.status = "some string";
```

which triggers the statuschanged event. Then that string is presented to you in your Xojo statuschanged event handler for the HTMLViewer.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 24, 2018, 4:12pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/25 "2018-08-24T16:12:24Z")

</div>

[quote=402431:@Tim Streater]Inside your HTMLViewer you do:

```auto
window.status = "some string";
```

which triggers the statuschanged event. Then that string is presented to you in your Xojo statuschanged event handler for the HTMLViewer.[/quote]

Duh. I’m an idiot, of course 🙂 Sorry, I’m not thinking straight.

Has anyone verified the limitations in length? I’ll try passing long text until I hit it.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [August 24, 2018, 4:26pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/26 "2018-08-24T16:26:58Z")

</div>

The `Window.Status` method no longer works as of 2017r1 because of the CEF update.

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 24, 2018, 4:37pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/27 "2018-08-24T16:37:30Z")

</div>

> [@402436:@Tim Parnell](#):
>
> The `Window.Status` method no longer works as of 2017r1 …

Under Windows. Seems to still work OK for macOS 2018r2.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 24, 2018, 4:43pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/28 "2018-08-24T16:43:00Z")

</div>

To sum up our javascript string functions, we have:

So we do have for Mac:  
HTMLViewer.[EvaluateJavaScriptMBS](http://www.monkeybreadsoftware.net/htmlviewermac-htmlviewer-method.shtml#24)(code as string) as string

And WebKit 2.x for Mac 64-bit:  
[WKWebViewControlMBS](http://www.monkeybreadsoftware.net/control-wkwebviewcontrolmbs.shtml).EvaluateJavaScript(JavaScript as String, Tag as String = “”)

For Linux with WebKit:  
[LinuxWebViewMBS](http://www.monkeybreadsoftware.net/class-linuxwebviewmbs.shtml).EvaluateScript(script as string) as string

For Windows with Internet Explorer:  
HTMLViewer.[IERunJavaScriptMBS](http://www.monkeybreadsoftware.net/htmlviewerwin-htmlviewer-ie-method1.shtml#7)(JavaScript as string) as boolean

For Windows with WebKit:  
[ChromiumBrowserMBS](http://www.monkeybreadsoftware.net/class-chromiumbrowsermbs.shtml).ExecuteJavaScript(jsCode as string, scriptUrl as string, startLine as integer)

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 24, 2018, 4:55pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/29 "2018-08-24T16:55:57Z")

</div>

[quote=402439:@Christian Schmitz]To sum up our javascript string functions, we have:

So we do have for Mac:  
HTMLViewer.[EvaluateJavaScriptMBS](http://www.monkeybreadsoftware.net/htmlviewermac-htmlviewer-method.shtml#24)(code as string) as string

And WebKit 2.x for Mac 64-bit:  
[WKWebViewControlMBS](http://www.monkeybreadsoftware.net/control-wkwebviewcontrolmbs.shtml).EvaluateJavaScript(JavaScript as String, Tag as String = “”)

For Linux with WebKit:  
[LinuxWebViewMBS](http://www.monkeybreadsoftware.net/class-linuxwebviewmbs.shtml).EvaluateScript(script as string) as string

For Windows with Internet Explorer:  
HTMLViewer.[IERunJavaScriptMBS](http://www.monkeybreadsoftware.net/htmlviewerwin-htmlviewer-ie-method1.shtml#7)(JavaScript as string) as boolean

For Windows with WebKit:  
[ChromiumBrowserMBS](http://www.monkeybreadsoftware.net/class-chromiumbrowsermbs.shtml).ExecuteJavaScript(jsCode as string, scriptUrl as string, startLine as integer)[/quote]  
Do you have a replacement event for status?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 24, 2018, 4:57pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/30 "2018-08-24T16:57:09Z")

</div>

We can’t make an event unless you’d use our control instead of Xojo’s.

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 24, 2018, 5:28pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/31 "2018-08-24T17:28:14Z")

</div>

That, I understand. In the event that status stopped working, I’d need an HTMLViewer-like control with a cross platform way of passing data from javascript running in the control, to a Xojo event.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 24, 2018, 5:34pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/32 "2018-08-24T17:34:50Z")

</div>

Well, if the OS no longer calls the event, Xojo can’t pass it to you.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 24, 2018, 6:20pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/33 "2018-08-24T18:20:41Z")

</div>

> [@402438:@Tim Streater](#):
>
> Under Windows. Seems to still work OK for macOS 2018r2.

I was wondering about Tim’s comment. Looking about this I found this from @Bob Keeney last year saying precisely that StatusChanged no longer works: [https://www.bkeeneybriefs.com/2017/03/xojo-2017-release-1/](https://www.bkeeneybriefs.com/2017/03/xojo-2017-release-1/)

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 24, 2018, 9:00pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/35 "2018-08-24T21:00:18Z")

</div>

> [@402454:@Eduardo Gutierrez de Oliveira](#):
>
> I was wondering about Tim’s comment. Looking about this I found this from @Bob Keeney last year saying precisely that StatusChanged no longer works: [https://www.bkeeneybriefs.com/2017/03/xojo-2017-release-1/](https://www.bkeeneybriefs.com/2017/03/xojo-2017-release-1/)

Well, my app is using HTMLEdit and is receiving the statuschange event (macOS Mavericks, Xojo 2018r2); I just tried it. So there it is.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [August 24, 2018, 9:58pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/36 "2018-08-24T21:58:02Z")

</div>

> [@402473:@Tim Streater](#):
>
> Well, my app is using HTMLEdit and is receiving the statuschange event (macOS Mavericks, Xojo 2018r2); I just tried it. So there it is.

Yes, we get it, StatusChanged is fine on Mac. But since it’s not cross-platform it is not a solution.

HTMLEdit 2 from GraffitiSuite was entirely rewritten to chunk data out through `TitleChanged` for this very reason.

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [August 25, 2018, 11:39am UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/37 "2018-08-25T11:39:22Z")

</div>

> [@402475:@Tim Parnell](#):
>
> Yes, we get it, StatusChanged is fine on Mac. But since it’s not cross-platform it is not a solution.

Well I do know that, in fact. It was when I was first testing out my app on Windows that I discovered this, then looked at titleChanged, then discovered titleChanged had a platform-dependent length limitation. But my only point was that Eduardo appeared to be saying that it didn’t work at all.

> [@](#):
>
> HTMLEdit 2 from GraffitiSuite was entirely rewritten to chunk data out through `TitleChanged` for this very reason.

One for me to look at, then. Although I’d prefer Xojo to do something too.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [August 25, 2018, 12:34pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/38 "2018-08-25T12:34:24Z")

</div>

I just made a new blog article today: [HTMLViewer JavaScript communication for Xojo](https://www.mbsplugins.de/archive/2018-08-25/HTMLViewer_JavaScript_communic)

---

<div class="post-metadata">

**Author:** ![Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/user_avatar/forum.xojo.com/eduardo_gutierrez_de_oliveira/32/264_2.png) [@Eduardo\_Gutierrez\_de\_Oliveira](https://forum.xojo.com/u/Eduardo_Gutierrez_de_Oliveira)\
**Post date:** [August 25, 2018, 10:25pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/39 "2018-08-25T22:25:04Z")

</div>

> [@402521:@Tim Streater](#):
>
> But my only point was that Eduardo appeared to be saying that it didn’t work at all.

I hadn’t tried it. I just mentioned that I’d read it didn’t work cross-platform (which is what I need it for).

Thanks to all, by the way. While I had used HTMLViewers a lot I had never had to get results back and it’s been very educational.

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [September 6, 2020, 8:16am UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/40 "2020-09-06T08:16:13Z")

</div>

6 posts were split to a new topic: [Returning Data to Xojo Web App](https://forum.xojo.com/t/returning-data-to-xojo-web-app/56757)

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:45pm UTC](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378/41 "2020-10-29T17:45:46Z")

</div>



[Previous page](https://forum.xojo.com/t/get-javascript-variables-back-from-htmlviewer-without-changing-the-title/24378.md?page=1)
