Is there a way to enable horizontal scrolling for a div table within an iframe element?

Looking for a solution to scroll a table horizontally to specific locations by clicking anchor tags outside of its frame? I initially used inline js which worked with the old table, but after updating to CSS, it stopped working. Seeking assistance from experts out there! Thanks in advance.

Sample code being utilized:

HTML frame referring to the frame containing the table:

<iframe src="PrimaryTables.html" id="FrameTableIsIn" name="FrameTableIsIn" scrolling="yes" align="middle" height="1350" width="100%" marginwidth="0" marginheight="0" frameborder="no"></iframe>

HTML Document inside iframe (FrameTableIsIn):

<div class="container" id="contained">
<table width="100%" cellspacing="1" cellpadding="0" border="0" id="primerows">
<tr>
    <td class="fixed">STUFF HERE</td>
    <td class="fixedspecial"align="center" valign="middle">STUFF HERE THAT OVERLAPS THE PREVIOUS TD STUFF NICELY</td>
    <td>OTHER STUFF HERE REPEATING COLUMNS</td>
</tr>
</table>
</div>

A long table with rows and columns handled nicely with CSS, as shown below:

<style>
td, th {
    white-space: nowrap;
    min-width: 100px;
    height:32px;
    vertical-align: middle;
}
.container {
    overflow-x: scroll;
    margin-left: 100px;
}
.fixed {
    height:30px;
    border: 1px solid #000000;
    position: absolute;
    left: 0;
    display: inline-table;
    text-align: center;
    vertical-align: middle;
}
.fixedspecial {
    border: 1px solid #000000;
    position: absolute;
    left: 0;
    height:35px;
}
</style>

Inline java script on page outside of iframe to affect document inside FrameTableIsIn:

<A HREF="javascript:parent.InitialFrame.FrameTableIsIn.scrollTo(110,0);parent.InitialFrame.scrollTo(0,50);" TARGET="InitialFrame">Link Text Here</A>

Previously, clicking the link would scroll the table horizontally to the specified location and then jump to the top of the page. However, with CSS, the horizontal scroll doesn't work due to the scroll feature being confined within the div element. Need help with proper handling...

If possible, prefer inline java to avoid cluttering the code further and bringing back memories of Pascal coding!

Answer №1

After encountering the challenge of calling into an iframe to access a div table using inline javascript, I discovered that there is no straightforward method to achieve this from outside the iframe. To overcome this issue, I decided to extract the table from the iframe, assign an id (DivTable) to the div, and successfully implement the inline javascript as follows:

<A HREF="javascript:parent.InitialFrame.DivTable.scrollTo(2580,0);" TARGET="InitialFrame">LINK HERE</a>

With this solution, my links now smoothly scroll my Div Table with fixed columns to the specified location defined by the scrollto function. It's important to note that InitialFrame represents the frame shared by the table and links, while the target attribute could possibly be (_top), although I have not tested this as everything currently works perfectly :). Hopefully, this explanation proves beneficial for someone facing similar challenges in the future...

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

Instructions for receiving user input and displaying it on the screen, as well as allowing others with access to the URL to view the shared input provided by the original user

<h1>Lalan</h1> <input type="text" name="text" id="text" maxlength="12"> <label for="text"> Please enter your name here</label> <br><input type="submit" value ...

Adjust the height of an element when the maximum height is set to none

I am trying to add animation to the opening of a menu on my website. This is achieved by adjusting the max-height property of the <div> element that represents the menu, as well as changing the display property. The max-height value is being changed ...

Creating customized placeholders using CSS padding in HTML5

I came across this helpful post and attempted various methods to adjust the padding for my placeholder text, but unfortunately, it seems unwilling to cooperate. Below is the CSS code. (EDIT: This CSS was generated from SASS) #search { margin-top: 1px; ...

Step-by-step guide for implementing tooltips using jQuery

I've been attempting to implement a tooltip using jQuery UI. However, when I use var_dump I am not getting any output. Here is the code snippet: <a href="#"><span id='11111_22222'>text_here</span></a> And this is ...

PHP problem encountered when trying to assign values to a dropdown menu from an array

Specifically, the error message that I am encountering is: *Notice: Array to string conversion in C:\xampp\htdocs\Project1_Tables\index.php on line 38 Notice: Array to string conversion in C:\xampp\htdocs\Project1_Tables ...

Utilizing HTML and JavaScript to dynamically switch stylesheets based on the width of

When it comes to using stylesheets for mobile and non-mobile devices, there is a need for different approaches. The idea of comparing browser height and width in JavaScript seems like a good one, but the implementation may not always work as expected. ...

Submitting forms that contain files using jQuery and AJAX

Despite searching through numerous questions on this topic, I have yet to find a solution to my specific issue. My objective is to successfully submit an entire form, potentially containing files as well. The code I currently have is not working: $(target ...

The filter designed for rearranging elements will not function

let wrap = document.querySelector(".wrap"); let temp = document.querySelector(".temp"); temp.addEventListener("click", (event) => { // grabs the first paragraph child element, which is working correctly console.log(wrap.children[0].firstElementChild ...

Adjust the width of the element to match the size of the image within

My webpage features an image along with some accompanying metadata that I want to be centered on the page. I want the div holding the metadata to be the same width as the image. Here's an example: Unfortunately, I am unable to determine the image&apo ...

Utilizing a JavaScript Regex to effectively search and replace the start of a string within a textarea on a global scale

I'm attempting to change any unencoded ampersands in a string using JavaScript and I'm curious if this is achievable. I have the regex set up to identify them in the string, but I'm concerned that replacing them will cause me to lose the par ...

Resizing the window triggers a speed up in the animation on ThreeJS

After examining the code below, I noticed that as the window is resized, the speed seems to increase rapidly. Can anyone explain why this is happening? <!DOCTYPE html> <html> <head> <title>Page Tit ...

"Exploring the features of next-auth server-side implementation in the latest version of Next.js,

Is it possible to utilize next-auth in a Next.js 14 application router to access user sessions and display page responses using SSR? If so, what steps need to be taken? ...

Ensure to pass the object as a prop while navigating to the new route

There's a function located outside the router view component. goToMarkets(){ this.$router.push({path: '/markets', params: {stock: this.model}}) } However, when this function is triggered, the prop remains undefined in the "Markets ...

Adding .js extension to relative imports in TypeScript compilation for ES6 modules

This particular issue may appear simple at first glance, but determining the required settings/configurations to resolve it is not straightforward. Below are the directory structure and source code for a Hello World program: Directory Structure: | -- Hel ...

Having trouble understanding why the border-radius attribute is not being applied to tables?

I've been trying to give the outer corners of tables a rounded appearance in HTML/CSS, but I can't seem to get the border-radius property to work properly. After inspecting the elements in Chrome's computed section, I noticed that the eleme ...

Can importing a library generate a fresh copy of the imported library?

In my development setup using webpack and vue-loader to build a Vue.js application, I have various .vue files for different components. Whenever I include the line: import _ from 'lodash' in the script section of both ComponentA.vue and Compone ...

"Angular: Enhancing Functionality with Nested Controllers and Service Dependency Handling

Hey there! I've got a setup with nested angular controllers. The outer one is called personController, while the inner one is personScheduleController. In this arrangement, the person controller reaches out to a service to retrieve person data. On the ...

Remove HTML tags from a table cell containing a combination of radio buttons and labels

Javascript Function: My JavaScript function posted below is designed to iterate through the column indexes specified in the 2nd parameter and also iterate through the element ids provided in the 3rd parameter. It will then populate the textbox, radiobutto ...

Refreshing backdrop for navigating through lists - Sprite edition

I am facing some issues while trying to use a sprite image for my navigation icons. The background position offset is not working as expected, and the background image is stretching across the whole length of the navigation. It seems like I may need to spe ...

``In a jade view, navigating through JavaScript object properties leads to the addition of quotation marks around strings

Utilizing the npm module traverse to filter data from mongodb / mongoose has been quite helpful for me. Here is an example of the kind of data I might receive: [ { rating: 5, title: { da: 'Web udvikling', en: 'Web Development' } } ...