{"slug": "embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the", "title": "Embedding a 360 virtual tour on any website: iframe vs. script, sizing and the gotchas", "summary": "The team behind Prewalk, a browser-based 360° tour tool, published guidance on embedding panoramic virtual tours into real estate and architecture sites, recommending an iframe plus a small script for responsive sizing and fullscreen, with a fixed-height iframe as a fallback when platforms like Wix or Google Sites block scripts. The writeup covers aspect-ratio CSS, lazy loading, the xr-spatial-tracking permission for VR mode, two-finger touch navigation, and CSP frame-src and host-side domain allow-listing as the usual causes of \"Refused to connect\" errors.", "body_md": "Real estate and architecture sites increasingly put a walkable 360° tour right on the listing page instead of linking out. Under the hood it's just an iframe, but there are a few decisions that decide whether it feels native or broken. This is what we've learned building embeds for [Prewalk](https://prewalk.co), a browser-based 360° tour tool, but most of it applies to any panorama viewer.\n\n**Iframe + a small script (the nicer option)**\n\n**Iframe only, fixed height (the fallback)**\n\n`<script>` tags (Wix, Google Sites and many CMS text fields do).\nRule of thumb: start with iframe + script. If the embed doesn't resize or full screen does nothing, the platform blocked the script, so switch to the fixed-height version.\n\nIf you can't run a script, at least let the browser keep the ratio:\n\n```\n<div class=\"tour\">\n  <iframe\n    src=\"https://example.com/embed/TOUR_ID\"\n    title=\"Apartment 3B: 360° virtual tour\"\n    loading=\"lazy\"\n    allow=\"fullscreen; xr-spatial-tracking\"\n    allowfullscreen>\n  </iframe>\n</div>\n\n<style>\n  .tour iframe {\n    width: 100%;\n    aspect-ratio: 16 / 9;\n    border: 0;\n    border-radius: 12px;\n  }\n  @media (max-width: 600px) {\n    .tour iframe { aspect-ratio: 4 / 5; } /* taller on phones */\n  }\n</style>\n```\n\n`loading=\"lazy\"` keeps a heavy WebGL viewer from competing with the rest of your page on first load.`xr-spatial-tracking` lets the viewer offer VR mode in headset browsers.`title` helps screen readers and is free.\nA 360° viewer wants every drag; your visitor wants to scroll past it. A good compromise is two-finger navigation on touch devices: one finger scrolls the page, two fingers look around. Prewalk exposes this as an embed option; if your viewer doesn't, at least avoid making the iframe full height on mobile.\n\nThe most common mistake: pasting the code into a normal text block, which just prints the HTML as text.\n\nIf your site sends a CSP header, the viewer's origin has to be allowed in `frame-src` (or `child-src`):\n\n```\nContent-Security-Policy: frame-src 'self' https://prewalk.co;\n```\n\nThe opposite direction matters too: the tour host may restrict which sites can embed it (Prewalk lets you turn embedding off or, on paid plans, allow-list specific domains). \"Refused to connect\" in the iframe is almost always one of these two.\n\nA tour shared as \"link only\" is not private once it's embedded: anyone who can open your page can watch it. Use password protection if that matters.\n\nIf you want to try this with your own panoramas, [Prewalk](https://prewalk.co) has a free plan with the embed code included, and the full walkthrough is in our guide: [Embed a tour on your website](https://prewalk.co/blog/embed-on-your-website). Happy to answer questions in the comments.", "url": "https://wpnews.pro/news/embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the", "canonical_source": "https://dev.to/prewalk/embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the-gotchas-436a", "published_at": "2026-11-15 21:42:33+00:00", "updated_at": "2026-11-15 21:51:00.626102+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Prewalk", "Wix", "Google Sites"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the", "markdown": "https://wpnews.pro/news/embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the.md", "text": "https://wpnews.pro/news/embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the.txt", "jsonld": "https://wpnews.pro/news/embedding-a-360-virtual-tour-on-any-website-iframe-vs-script-sizing-and-the.jsonld"}}