Ways to ensure that a responsive iframe target adheres to the dimensions of the iframe's viewport and behaves as though it is being viewed directly

Upon direct access, the website below demonstrates full responsiveness:

However, when embedded within an iframe, its responsiveness falters and fails to adapt to the browser width:

iframe {
         display: block;       /* iframes are inline by default */
         border: none;         /* Reset default border */
         height: 100vh;        /* Viewport-relative units */
         width: 100vw;         /* Viewport-relative units */
     }

<div class="iframeContainer">
   <iframe src="https://sherpasoftware.com/">
   </iframe>
</div>

https://jsfiddle.net/hb4w6sfn/

Various responsive iframe solutions were attempted without success on this specific site. It was observed that the target site applies a fixed width of 1093px when accessed through an iframe, contrary to its behavior when directly accessed and resized. This unique behavior hinders the implementation of standard responsive methods, indicating a discrepancy in how the site responds based on the method of access - directly or via an iframe.

The target site appears to detect differences when accessed through an iframe as opposed to direct access, although the exact reason remains unclear.

How can this issue be resolved to ensure the iframe behaves responsively like a traditional browser, adapting smoothly to changes in size?

Contrast the above unresponsive JSFiddle example, accessible both directly and via an iframe, with the following example which maintains responsiveness regardless of access method. The sole distinction lies in the URL.

iframe {
         display: block;       /* iframes are inline by default */
         border: none;         /* Reset default border */
         height: 100vh;        /* Viewport-relative units */
         width: 100vw;         /* Viewport-relative units */
     }

<div class="iframeContainer">
   <iframe src="https://www.economist.com/">
   </iframe>
</div>

https://jsfiddle.net/pjL7bm8d/

Answer №1

This seems to be a CORS issue with the website prosolutionplus.com. When opening the site in a separate tab with JavaScript disabled, it displays at 1093px just like when it's being iframed.

If you inspect the JavaScript console while iframing prosolutionplus.com, you'll encounter a CORS error message:

frontend.min.js?ver=2.4.5.1:5 Uncaught DOMException: Blocked a frame with origin "" from accessing a cross-origin frame.`

This issue appears to be related to the Thrive Editor. You can also refer to this Stack Overflow post on Cross-Origin restrictions and why they are enforced: SecurityError: Blocked a frame with origin from accessing a cross-origin frame

https://i.sstatic.net/cTcpS.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best approach to managing an ajax request when the endpoint could return either JSON data or load a new HTML page?

One dilemma I'm facing is how to efficiently handle an endpoint that may return either a JSON response or redirect to a different HTML page based on the parameters provided. In some cases, only JSON data is returned while in others, a new HTML page is ...

Mastering Instagram Automation: Techniques for Navigating the Lightbox with Selenium

I am in the process of developing a Python script that assists users in Instagram engagement groups by efficiently liking everyone's photo during each round. I am facing an issue where Selenium is unable to click on the first photo when I reach a user ...

CSS droplists are missing their scrollbars

const elements = document.querySelectorAll('.selectBtn'); const options = document.querySelectorAll('.option'); let zIndexValue = 1; elements.forEach(element => { element.addEventListener('click', event => { const ...

Is there a way to show text as symbols in Primeng components?

Check out this helpful example that demonstrates what I am attempting to achieve. I have implemented p-menu from primeng. Is there a method to convert text into symbols like &trade to ™ and &#8482 to ®? ...

Get the enterprise GitHub asset by utilizing an HTML anchor <a> tag or JavaScript

I'm trying to create a direct link to an asset file that allows any user to download the asset without needing to log in. An access token, abcd1234, has been generated. I've tried linking to the release by ID in the HTML, but it's not work ...

How can I repeatedly trigger an eventListener in JavaScript?

I'm currently facing an issue with calling the event listener for all 4 progress bars on my page. The problem is that it's only working on the first progress bar. I cloned the div with the id of 'mycontainer' using a for loop, but the e ...

What is the best way to continuously swap out images inside a div every second, except when the mouse hovers over

I recently posted a question on Stack Overflow about displaying an image in a div when a specific link is hovered over, and thanks to the help of user adeneo, I was able to find a solution (jsFiddle): HTML Markup: <div id="imgs"> <img src="h ...

I am experiencing issues with Google Fonts not functioning properly when I insert the bootstrap CDN

I have encountered an issue while working on my landing page. I am using Google fonts for the design and trying to integrate Bootstrap as well. However, whenever I add the Bootstrap link, all the font styles stop working. I have checked the order of the CS ...

Issues with jQuery animate not functioning properly when triggered on scroll position

I found a solution on Stack Overflow at this link, but I'm having trouble implementing it properly. The idea is to make an element change opacity from 0 to 1 when the page is scrolled to it, but it's not working as expected. The element is locat ...

How about displaying the Ajax response as an image?

I'm working on a script that pulls an image link, which seems to be functioning correctly. However, I am struggling with how to display the link as an image. Can someone please assist me with this? <script src="//ajax.googleapis.com/ajax/li ...

Controlling the scroll behavior of div elements with the CSS overflow-y property

This is the current setup I have: <div> <div> </div> <div> </div> <div> </div> </div> The inner divs are styled with this CSS: float: left; margin-right: 40px; width: 100px; While ...

Adjusting Window Size Causes White Space to Appear Above Div

I currently have two inline-block div in my post page that showcase my latest book reviews. Typically, these sections align perfectly and occupy the same amount of space on the screen. However, for certain window sizes, one of the inline-block elements end ...

Adjust modal size dynamically from the middle with JavaScript and CSS

Take a look at this fiddle example: http://jsfiddle.net/c2mmQ/ In the fiddle, I have implemented a modal using jQuery that fades in and scales up with CSS animations when the show link is clicked. Inside the modal, there is another link that is supposed t ...

Utilizing HTML Canvas: Incorporating a background image along with base64 data for enhanced visual effect

I am currently working on some JavaScript tasks in Laserfiche forms where I need to save the base64 data of an image in a separate text area. This data is then fed back into the image to convert the canvas into an image that can be saved in the system. On ...

Is it appropriate to include JavaScript and CSS in views?

In my ASP.NET MVC project, I have set up a _Layout, a controller, and several views. Certain pieces of code are clearly global in nature, such as the CSS included in the _Layout file and other styles that are consistent throughout the site. However, when ...

Using *ngFor to display the initial element from an array

Here is the code I am currently using: <div *ngIf="gamedata.notOver" class="columns"> <div class="column has-text-centered" *ngFor="let board of boards; let i = index"> <table class="is-bordered" [styl ...

How can I showcase Bootstrap cards horizontally within a razor foreach iteration?

I seem to be experiencing a mental block on how to arrange bootstrap cards in a horizontal layout using a for each loop. By default, they appear vertically. Below is my razor code: @foreach (var item in Model) { var imgUrl = Url.Content("~/Conte ...

Tips on utilizing radio buttons in place of check boxes

How can I create a dynamic menu with multiple categories and submenus that toggle open and close when clicked? I currently have a menu structure with "What's New" and "Categories", and within the "Categories" section, I have three main categories each ...

Ionic2 - Ion-select malfunctioning on a particular page

I have encountered an issue with the ion-select component in my Ionic 2 app. Specifically, when navigating to a certain page, the ion-select does not display properly. Strangely enough, on other pages of the app, this component works perfectly fine. Below ...

Execute JavaScript with URL parameters prior to finishing Page load

I have spent hours searching for a solution, trying different methods but none of them seem to work... Here is the code snippet I am struggling with: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>&l ...