JavaScript on Apple Silicon

Have an app that has worked on iPhone/iPad. It uses WkWebView and evaluateJavaScript() to try to read the contents of a web page. However, when trying on my new Apple Silicon mac with the My Mac (Designed for iPad) option, it gives me the following error.

Error Domain=WKErrorDomain
Code=4 "A JavaScript exception occurred"
UserInfo={WKJavaScriptExceptionLineNumber=0, WKJavaScriptExceptionMessage=Cannot execute JavaScript in this document,
WKJavaScriptExceptionColumnNumber=0,
NSLocalizedDescription=A JavaScript exception occurred}

So, not really sure if it is really an Apple Silicon problem, or just that the running on the Mac is the problem and permissions are different.

Environment details:
Mac mini (M1, 2020)
macOS Big Sur Version 11.2.2
Xcode Version 12.4