Search code examples
javascriptiframeweb-component

How can i call a web-component with a script call


I developed a web app with react and i want to embed it in another website, although i embedded it in the website through an iframe, there is a code below about it.

<iframe src="https://mapbox-project.netlify.app/" frameborder="0" height="560" width="100%"></iframe>
   

But, due to iframes limitations, i want to be able to embed it through a script call like this instead? I don't know if this might help to understand what I'm trying to achieve here.. https://blog.jenyay.com/web-ui-widget/

  <script src="https://mapbox-project.netlify.app/"></script>

But i really do not know how to go about it.


Solution

  • That's not possible. The only ways to embed another page is via an iframe, actual frames (if anyone still remembers them), or using embed. Script tags are for executing javascript code, but a page is not javascript code. Some web applications/APIs offer a JSONP variant for embedding where you can indeed call them via a script tag, e.g., but that would need to be enabled by the embedded application and requires additional work.