samedi 28 août 2021

HTML & JS: How to subscribe to events from an embedded webpage?

I'm experimenting with building modular stand-alone (serverless) websites that can be hosted on IPFS. One of the techniques I'm using to make the websites modular is by splitting single webpages across multiple HTML files and combining them by embedding them into each other,

for example:

Webpage files: Home.html, Sidebar.html

Code in Home.html:

    <html>
      <head></head>
      <body>
        <!some code>
        <object id="Sidebar" data="Sidebar.html"></object>
        <!some more code>
      </body>
    </html>

Here is an image of what the website looks like. Note the scroll-bar that shows the the sidebar is embedded.
Website-with-Embedded-Sidebar :

enter image description here

I want to make that when elements of text in the sidebar (in the embedded Sidebar.html) are clicked, the JavaScript in the main page (Home.html) can react,

i.e. I want my JavaScript in Home.html to subscribe to events in the embedded Sidebar,html.

Any ideas on how best to achieve this?




Aucun commentaire:

Enregistrer un commentaire