cd /news/developer-tools/embedding-a-360-virtual-tour-on-any-… · home › topics › developer-tools › article
[ARTICLE · art-170142] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Embedding a 360 virtual tour on any website: iframe vs. script, sizing and the gotchas

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.

by read2 min views1 publishedNov 15, 2026

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, a browser-based 360° tour tool, but most of it applies to any panorama viewer.

Iframe + a small script (the nicer option)

Iframe only, fixed height (the fallback)

<script> tags (Wix, Google Sites and many CMS text fields do). Rule 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.

If you can't run a script, at least let the browser keep the ratio:

<div class="tour">
  <iframe
    src="https://example.com/embed/TOUR_ID"
    title="Apartment 3B: 360° virtual tour"
    ="lazy"
    allow="fullscreen; xr-spatial-tracking"
    allowfullscreen>
  </iframe>
</div>

<style>
  .tour iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
  }
  @media (max-width: 600px) {
    .tour iframe { aspect-ratio: 4 / 5; } /* taller on phones */
  }
</style>

="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. A 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.

The most common mistake: pasting the code into a normal text block, which just prints the HTML as text.

If your site sends a CSP header, the viewer's origin has to be allowed in frame-src (or child-src):

Content-Security-Policy: frame-src 'self' https://prewalk.co;

The 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.

A 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.

If you want to try this with your own panoramas, Prewalk has a free plan with the embed code included, and the full walkthrough is in our guide: Embed a tour on your website. Happy to answer questions in the comments.

── more in #developer-tools 4 stories · sorted by recency
── more on @prewalk 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/embedding-a-360-virt…] indexed:0 read:2min 2026-11-15 · —