iOSHTMLViewer javascript alert

Trying to get an alert box to display in an iOSHTMLViewer from javascript. alert("Foo"); gives me nothing. Is there an alert alternative?

More info - these are from within large chunks of js code used for debugging, not triggered by events. Specifically, debugging a d3.js based chart that works fine on the Mac implementation, but disappears in iOS.

Anybody?

Don’t have a specific answer. But would recommend you try with 2018r1.1 build that uses ios11 sdk. Might be an issue there. Also might get better response in the IOS target section on the forum rather than general.

Thanks. Was unaware there was an iOS target section.

Where is 2018r1.1 ?

pre-release tests. It should not be discussed outside of pre-release, but it is obvious to all that some issues present in 2018 R1 need a quick fix. That is precisely what dot 1 releases did in the past with previous releases, and this is what this one will do also.

How do you load your JavaScript ? I just tried alert(‘foo’) in a very basic HTML page script, it works perfectly, and displays like a Messagebox.

There may be other issues in your Javascript code that prevent any subsequent execution.

Agreed - I have done the same… but this is within a separate page, and I suspect that the alert is being targeted elsewhere. I can’t see how to target an alert to a specific page.

Have you brought up said page in Safari on an ipad and seen if it has the same issue?

What do you mean “this is within a separate page” ? AFAIK alert is always related to the current view (window).

That is what I had hoped; A barebones HTML page consisting of just a script tag and alert worked fine. An alert embedded in the html of my large project worked fine. The alert I had embedded inside a (more complex) js function, that was supposed to be issued once relevant data had been processed, never appeared.

As a workaround, I declared a global variable, assigned a property and value(s) to it inside the function, and attached an alert to a button that displayed the contents of once I knew the data were available. I would be curious to know why an alert cannot be displayed from inside a function, but does so fine outside it.

The most probable explanation is that the code did not execute in that portion of the program. Add another alert at the beginning of the function. I bet something halts execution and returns before you have a chance to display the completed alert.

I am not sure the iOSHTMLViewer is able to display the black JavaScript error box. If not, then you may have an error that stops execution and the script fails silently.

Ideally, in JavaScript, one could use console.log() which is the equivalent of system.debuglog() in Xojo.

You may want to activate the debug console on the device
http://osxdaily.com/2012/05/07/enable-safari-debug-console-ios/

In the simulator, it is less clear. I did not have time to investigate and test :
https://stackoverflow.com/questions/6508313/javascript-console-log-in-an-ios-uiwebview