Alert gives script error on ios firefox

Hi,

I get the following error on Firefox on IOS. This works for Safari and Chrome on IOS. Also Firefox, Chrome, Safari on MacOS.

I have tried both Material Design and M3 Design theme.

from ._anvil_designer import Form1Template
from anvil import *


class Form1(Form1Template):
    def __init__(self, **properties):
        # Set Form properties and Data Bindings.
        self.init_components(**properties)

        # Any code you write here will run before the form opens.
        alert("hello")

Am i missing something fundamental?

Likely an issue in the IOS firefox that has a script error that they are not handling, which Anvil is surfacing.

Moved to bug reports and we’ll see what we can do.

For now, you’ll want to handle this in your startup module/form with a default error handler that ignores this error.

1 Like

Thanks!

Do you mean something like this:

try:
    alert("hello")
except:
    pass

Sadly i have no success :confused:

My bad i found the workaround.

from ._anvil_designer import Form1Template
from anvil import *
import anvil.js

class Form1(Form1Template):
    def __init__(self, **properties):
        anvil.js.window.onerror = lambda msg, *args: str(msg) == "Script error."
        self.init_components(**properties)
        alert("hello")

ah sorry

i meant this

import anvil

# Put this in startup form

def error_handler(err):
  if str(err) == "Script error.":
    return
  else:
    raise err

anvil.set_default_error_handling(error_handler)
1 Like