Skip to content

Consistent & Reliable iFrame Embed & Autosize #446

@wesleyboar

Description

@wesleyboar

Embedding iframe on a page has problems.

Known Clients

Problems

1: Full-Width IFrame Limitations

The "Standard" CMS Template is not for full-width content. It reduces and quantizes width of page content. The iframe is too narrow.

Solutions

1.1: Create New CMS template

Create a new CMS template "Standard (with iFrame)".

1.2: Use CMS Template "Full Width"

Warning

Page will not have breadcrumbs.

1.3: Use JavaScript

We have temporary, dynamic solutions with JavaScript.


2: Title Appearance is Inconsistent

Embedded graphs have title, rather than letting the page set the only title. Title in the iFrame does not match CMS design. Hide the title in the context of an iFrame.

Solutions

2.0: "Just Delete the Title"

Just do not add the title in the app to begin with.

Note

2.1: "Separation of Concerns" JavaScript & CSS

// JS
document.addEventListener("DOMContentLoaded", function () {
    if (window.self === window.top) {
        document.documentElement.classList.add('is-standalone');
    }
});
html:not(.is-standalone) h1 {
    display: none;
}

2.2: "One Language for the Luddite" JavaScript

document.addEventListener("DOMContentLoaded", function () {
    if (window.self !== window.top) {
        // Page is in an iframe
        document.getElementById("yourElementID").style.display = "block";
    } else {
        // Page is not in an iframe
        document.getElementById("yourElementID").style.display = "none";
    }
});

2.3: "I Wanna Learn the Future" CSS & JavaScript

@media all and (display-mode: browser) {
    #yourElement { display: none; }
}

And learn display-mode and how to implement it (JavaScript).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions