Code snippets in posts are executed on <iframe>
in sandbox mode; with the follow permissions: sandbox="allow-modals allow-scripts"
. The option allow-forms
is not added probably due to security concerns; this for sure it's a good idea.
The thing is that today I come across this answer, which relies on a code snippet sample which use submit
event to work, and of course it's blocked when it runs in Chrome; and in this case the example in the answer fails showing the correspondent error in the console:
Blocked form submission to '' because the form's frame is sandboxed and the 'allow-forms' permission is not set.
I simple edit the question to bind the validate function to the click event on button instead of a <form>
, so no problem at all, but my concern is:
Could be a good idea when a submit form is detected in a code snippet to advise the user that this not will work?
allow-forms
permissions despiste the example.preventDefault()
seems to work in Firefox (v50) but not in Chrome (v55). See, e.g., stackoverflow.com/a/28324083. Is there a good reason why?