Using Micro Web SDK via iframe

  • 18 December 2023
  • 1 reply
  • 46 views

Badge

Hello! Can I use Miro Web SDK if I embed my boards via iframe to my application? (I connected board as here Live Embed with BoardsPicker for registered users (miro.com))

I want to do that:

const item = await miro.board.get({ id: id })

await miro.board.viewport.zoomTo(item)

but I don’t understand how to get miro object from iframe in my application.


I tried to do that:
document.getElementsByClassName('miro-embedded-board')[0].contentWindow.miro, but I get error: Uncaught DOMException: Failed to read a named property 'miro' from 'Window': Blocked a frame with origin “https://my-link” from accessing a cross-origin frame.
    at HTMLDocument.<anonymous>

Thanks.


1 reply

Badge

Hey Anatoly, thank you for reaching out us. By default it is not possible to access iframe’s JavaScript scope if the source has a different origin. It would be a huge security leak if you could do this.

If you’d like to have a Miro board loaded and focused on a specific widget from the start, you can you the `moveToWidget` parameter in the URL:

https://miro.com/app/live-embed/{board_id}/?moveToWidget={item_id}

More about the parameter you can find in documentation: https://developers.miro.com/docs/miro-live-embed-with-a-direct-link#set-the-initial-view-based-on-a-specific-board-item

 

Reply