I use iframe in Babylon , but when i want to use it on my local host i get the "Blocked a frame with origin "https://www.youtube.com" from accessing a cross-origin frame" error?

hello everyone

i use the iframe in my babylonjs code, and there is no issue in my playground, but when i want to have it on my local host i. got the Blocked a frame with origin "https://www.youtube.com" from accessing a cross-origin frame. i want to know how can i solve this problem?

The solution may depend on your local environment settings. There are different workarounds which solve this problem, here are some links:

2 Likes

Thank u so much :pray: :pray: :pray:

1 Like

This error is not a bug. The same-origin policy is a security mechanism that ensures that window objects only have access to the informations they are authorized to get.

The window.postMessage() method provides a controlled mechanism to securely circumvent this Same-Origin Policy restriction. The window.postMessage() safely enables cross-origin communication between Window objects; e.g: between a page and an iframe embedded within it.

postMessage(message, targetOrigin)
postMessage(message, targetOrigin, [transfer])

targetOrigin - specifies what the origin of targetWindow must be for the event to be dispatched, either as the literal string “*” (indicating no preference) or as a URI.