Enable WebKit debugger in FileMaker Web Viewer

If you are having difficulty getting your HTML, CSS, or JavaScript to render in a FileMaker Web Viewer, you may have a struggle ahead of you trying to find the problem, and no good way to debug it. In comparison, most web browsers have debug facilities that can help developers find problems in their code.

Updated for FileMaker 16: This article was originally published July 20, 2015. It has been updated to cover FileMaker 16 and enabling the WebKit debugger with Web Viewers.

It turns out if you are using macOS you can get the same facilities found in Safari to debug your code that’s running in a FileMaker Web Viewer.

Enabling Web Inspector

To do this we need to first enable a hidden option. Quit any open copies of FileMaker and start up the Terminal app to execute one or more versions of the command below.


For FileMaker Pro 16 Advanced (Yes, advanced12 is correct for version 16):

For FileMaker Pro 16:

An important caveat with FileMaker 16 however is that the integrated/attached version will cause FileMaker Pro to crash when you quit. To avoid this, use the window mode buttons at top-left after the Inspector opens:

Safari Inspector window mode buttons

You can also try setting the Inspector’s default window mode, however this did not work consistently for us:


For FileMaker Pro 14 & 15 Advanced:

For versions Pro 14 or Pro 15:


For versions 12 Advanced or 13 Advanced:

For Pro 12 or Pro 13 use:


Using Web Inspector

Start FileMaker back up, and navigate to a layout with a Web Viewer on it. Right-click on a Web View, and select Inspect Element from the contextual menu. Voila! You can now debug HTML, CSS, and JavaScript in any Web Viewer.

Web Viewer contextual menu
Safari debugger in Web View

If you are debugging JavaScript and are trying to catch your code in action, there are some minor tricks required.

One issue is that the debugger will go away whenever the Web Viewer is not displayed. Annoyingly, this also takes any breakpoints you’ve set with it. So for debugging JavaScript code you probably want to take advantage to the debugger extensions added to JavaScript. These are documented on table 5-2 of the Safari Inspector Guide.

A partial list of functions are:

  • console.assert(expression, object)
  • console.log(object)
  • console.profile([title])
  • console.trace()
  • debug (expression)
  • debugger

None of these debugger functions will work until the Inspector has been activated, so enable it as soon as possible with the contextual menu on the Web Viewer. But at least the debugger breakpoints will persist each time the web viewer is reloaded.

Simon

 

References

5 thoughts on “Enable WebKit debugger in FileMaker Web Viewer

Leave a Reply