Google Maps iframe doesnt work with sandbox

Viewed 330

My Google Map iframe stops working after adding the sandbox attribute. I tried to embed the map without it and it worked. I'm not sure why and would be happy for help

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d244882.93248659256!2d-96.26493913191504!3d41.29067020779935!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sil!4v1630314849966!5m2!1sen!2sil" 
  width="550"
  height="450"
  style="border:0;"
  allowfullscreen
  loading="lazy"
  sandbox="allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-top-navigation"
></iframe>

If I remove the sandbox attribute, it works again.

1 Answers

Google Maps requires, at minimum, allow-scripts:

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d244882.93248659256!2d-96.26493913191504!3d41.29067020779935!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sil!4v1630314849966!5m2!1sen!2sil" 
  width="550"
  height="450"
  style="border:0;"
  allowfullscreen
  loading="lazy"
  sandbox="allow-scripts"
></iframe>

You can add extra things as you wish. Here's a list I found from Discourse:

sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation"

But if script execution is blocked, the map is not going to load.

Related