The help page for web browser objects tantalisingly states at the end:
To learn more, see Panorama/JavaScript Interface
but unfortunately that’s a link to a non-existent anchor on the same page. I see a training video covering this subject was made five years ago. Has anything been written up since?
The web browser object uses an Apple class called WebView. Apple has now replaced this with a new class called WKWebView. On iOS they have discontinued WebView, but for now macOS contains both of these classes. I think this is because WKWebView does not include all of the features that WebView has, and some popular web authoring apps will completely break if WebView is discontinued. WKWebView uses a somewhat different communication interface from WebView. Apple has stated that they plan to discontinue WebView, but so far has not made any move to add the additional features to WKWebView. So the future on this topic is rather cloudy.
I’m mentioning this because presumably Panorama is going to need to switch to WKWebView at some point, and I’m not sure how (or if) that will affect the Panorama/JavaScript interface. So at a minimum, I don’t plan to write any additional documentation for this until this question is cleared up.
It appears this still hasn’t been settled, but I imagine my question can be answered. Can the browser load a separate javascript file from disk and run it? It’s handling CSS and images, but so far has been unresponsive to my attempts to run scripts.
to control the contents of the browser or to return information from it.
In this case it’s a displaying map tilesets in a Panorama X web browser object using Javascript built on the OpenLayers library. Most of the functionality is in the Javascript, but Panorama is used for the user interface — selecting maps, scales, layout etc. Previously running the site in Safari, all that UI control was done using a nasty Javascript menu. Now using Panorama to display and control it, via Javascript functions, is a huge improvement (as far as it goes at the moment, since I haven’t had time to finish it).
I’ve tried it in Literal Text and Formula mode, and I’ve tried it bracketed between pipes: |||.
My first character is “<” and doctype vs DOCTYPE doesn’t change anything.
I suspected that maybe it was the curly brackets causing it to fail so I created an external js file. Still no results in every manner that I tried it. Listfiles( confirmed that my external script was correctly located. As with a previous test, an external CSS file in the same location was read and applied.
So far I’ve watched the movie, read the Help file, and searched this forum without finding the solution.
the web browser object initially displays ‘Initial setting’, and then the following Panorama command successfully calls the javascript function definied in the HTML header to change ‘Initial setting’ to ‘New’ in the web browser object:
local Result
objectaction "WebBrowserObject", "script", {settext("New");}, Result
I’m not 100% sure, but I think the javascript alert( function doesn’t work in the web browser object. You’re restricted to actions within the object itself, you can’t jump out and display other windows or alerts. In any case, I tried your code in a completely external file made with BBEdit, it seemed to work in Safari but would not work in a web browser object.
Well that was pretty helpful. alert( has been the easiest way to test to see if a javascript is being hit and/or run when building web sites. It’s an odd omission but so be it. Using innerHTML I confirmed that it does run from within the HTML and can run from an external script too. And both can exist in the same HTML, as they should.
What brought me to this was that I was unable to get chart.js to load or run as far as I could see. Thus my Click Me tests. Although I’ve had success using the ploty.js built into Panorama (Very Nicely Done, I must say ), I’ve been looking for a single solution that I can use for both desktop presentations and for Panorama Server publishing the same charts as web pages; whichever is being called for from the same database.
Unless I’ve missed something, there’s no simple way to load the ploty results into an HTML page being published by Pan Server.
Plotly.js was designed for web publication, that’s its entire purpose. Of course a public web page can’t access the version of plotly.js that is installed inside Panorama, but you can certainly install plotly.js on your web server and use that. I think there might be a publicly available version of plotly.js as well, but it’s been a long time since I looked at that so my memory might be fuzzy there. But I would think you would want your own copy installed on your server anyway.
All understood, I was wondering though about taking the very same procedure used in Panorama with just a late change in the process to channel it one way or the other. NOT a gripe but a recognition that it will probably take two entirely different processes or I interface directly with ploty and send it into the Web Browser object or to the web connected browser via PanX server.