Ways to navigate a div within an iframe that has been loaded

As I load a page(A) inside an iframe, the HTML structure of the embedded content is as follows:

<html><body>
<div id="div1"></div>
<div id="div2"><button>Hello</button></div>
</body></html>

The iframe is included in the parent page like this:

<html><body>
<iframe src="pageA.html" height="200px"></iframe>
</body></html>

In this setup, div2 remains fixed at the bottom of the page while div1 has a scrollable overflow. Upon clicking the button within div2, new content is added to div1.

To ensure that the newly appended content in div1 is visible within the iframe, there is a need to scroll down div1 to its bottommost position. How can this be achieved?

Edit: I have implemented a solution in a JSFiddle. The approach works when viewing the HTML directly in a browser but doesn't seem to function correctly when loaded within a fixed-height iframe.

Answer №1

The most recent addition can be found towards the end. JSFiddle Link.

<iframe src="http://example.com/fiddle123/show/" height="250px"></iframe>

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

Span element not displaying as a clickable hyperlink

The magnifying glass icon inside the orange search bar at the top of this page is not appearing as a link, so when hovered over there is no pointer.. Any thoughts on why this might be? Below is the CSS: .searchGlass { background-image: url(/images/search ...

Whenever the page is refreshed, the props in my application are dynamically updated thanks to the getStaticProps function I utilize

Currently, I am in the process of learning nextjs as a beginner. Through the utilization of the getStaticProps function, I have come to understand that data fetching occurs only once at build time and the values remain static thereafter. Despite this, I ...

Having trouble with the lodash find function in my Angular application

npm install lodash npm install @types/lodash ng serve import { find, upperCase } from 'lodash'; console.log(upperCase('test')); // 'TEST' console.log(find(items, ['id', id])) // TypeError: "Object(...)(...) is un ...

Modifying Copyright Feature in Footer

I am attempting to implement this function within my dark-colored footer: import Typography from '@material-ui/core/Typography'; function Copyright() { return ( <Typography variant="body2" color="textSecondary" align="center"> ...

jquery struggles to understand jsonp data during cross-domain heartbeats

I have embedded my module, which is an asp.net project, within a "portal". The portal creates an iframe that points to my URL. I understand that this setup may not be ideal, but it was not something I could control. To prevent the session on the main "po ...

Leveraging AngularJS to Connect Controller Functions with Service Attributes

Just dipping my toes into the world of ngJS. I've managed to successfully bind the service objects to controllers. Is this the best way, or is there a more recommended approach? I'm also curious why this functionality seems limited to objects ...

show the popover only once the cursor has been hovering for a couple of seconds

Looking to customize the behavior of a bootstrap popover? Here's an example of using the popover to trigger on hover: $("#example").popover({ trigger: "hover" }); However, if you want the popover to appear after a few seconds of hover (e.g. 2 ...

How to Retrieve Superclass Fields in Angular 5 Component

I have a superclass that provides common functionality for components. export class AbstractComponent implements OnInit { public user: User; constructor(public http: HttpClient) { } ngOnInit(): void { this.http.get<User>(& ...

Is there a discrepancy in the JSON algorithm?

While using google chrome, I encountered the following scenario: I had an object in javascript that looked like this: var b = { text: 'hello world, you "cool"' }; I then used JSON.stringify to convert it to a string and sent it to the dat ...

Is there a way to transfer the chosen maximum and minimum price values to a JavaScript function within a select tag in HTML?

I have a search form that includes select options with two values. However, I want to have two select options for both the Max and Min price values. <input type="hidden" id="budget_min" name="filter_budget_min" value="0" /> <select onchange="upda ...

What could be the reason for my ng-init not functioning properly?

<body ng-init="user=${userID};month=${month};curPageNum=${currentPage}"> Using JSP, I set initial values in the body tag. However, in the controller, I have the following code: console.debug($scope.user + " "+$scope.month} The issue is that only ...

Applying toggle() function with a boolean status indicator and a specified time frame

I have a question regarding toggling a div using jQuery: $(this).closest(".email-settings").find(".notify-email-input").toggle(this.value === "true"); Typically, you can make the toggle animation slow by adding .toggle(' ...

showcasing a specific item within an array using magnific-popup

I am dealing with an array of items structured like this: items: [ { src: '#white-popup0', type: 'inline' }, { src: '#white-popup1', type: 'inline' }, { src: '#white-popup2', type: ...

Initiate the timer in JQuery

function begin() { rMinutes = Math.floor((Math.random() * 1) + 1); rSeconds = Math.floor((Math.random() * 59) + 1); $('#minutes').text(rMinutes); $('#seconds').text(rSeconds); int1 = setInterval(function timer() { i ...

How can I incorporate dynamic moving lines into my website's loading sequence?

Link to Gyazo image 1: https://gyazo.com/015425f0decb187e28b620c1e3206391 Issue with first image: https://gyazo.com/dfcd33e8a4fd5bea64e51fe40556f0bf I'm currently working on a website and came up with a cool concept of having two lines crossing the s ...

Struggling with filtering an array fetched from an API using VueJS

Currently, I am working on a Nativescript-Vue app and facing some challenges that I need help with. The Scenario I have data coming in from an API. Here is the structure of the data I receive: { "count": 9, "results": [ { "id": 1, "c ...

Ensuring the input field and button are positioned in a horizontal line

Currently, I am developing a to-do list application using React and Chakra UI. I am trying to align the input field and the button on the same line for a more organized layout. This is the current layout: image I aim to achieve a design similar to this: ...

I am encountering difficulties with importing Node modules into my Vue.js project

Having some trouble importing a node module via NPM in a Vue.js single file component. No matter which module I try to install, it always throws an error saying These dependencies were not found. I'm following the installation instructions correctly ( ...

Attempting to eliminate the parent container of a slide generated by the Slick Slider Plugin

I have developed a filter mechanism that hides specific classes within a slick slider based on the data-tag associated with the objects and the value of checkboxes. However, when these classes are hidden, they still occupy space because I should be hiding ...

A guide on detecting overflow in a React functional component

I am in search of a way to determine if a div contains overflowing text and display a "show more" link if it does. While researching, I came across an insightful Stack Overflow answer on checking for overflow in a div. The answer suggests implementing a fu ...