Chrome is inaccurately reporting the outerHeight value, while IE and FireFox are displaying it correctly

The jquery.smartWizard plugin includes a function called fixHeight that adjusts the height of a wizard step. It is utilized when displaying a step for the first time or revealing hidden divs within the step. The function works correctly in IE and FireFox, but in the latest version of Chrome, there is a discrepancy where the outerHeight value is significantly smaller than expected, by more than 100 pixels.

Below is the original function:

SmartWizard.prototype.fixHeight = function(){
    var height = 0;

    var selStep = this.steps.eq(this.curStepIdx);
    var stepContainer = _step(this, selStep);
    stepContainer.children().each(function() {
        if($(this).is(':visible')) {
             height += $(this).outerHeight(true);
        }
    });

    // These values (5 and 20) are experimentally chosen.
    //stepContainer.height(height);
    //this.elmStepContainer.height(height + 12);

    stepContainer.animate({ "height": height - 12 }, 500);
    this.elmStepContainer.animate({ "height": height }, 500);
    alert(window.outerHeight);

}

I have made adjustments to incorporate animations into the final steps. However, the issue persists whether using Chrome or not.

EDIT: I have created a fiddle to showcase the difference between IE and Chrome. When you click on 'member' and then 'non-member', you will notice different height values displayed in each browser. http://jsfiddle.net/xjk8m8b1/

EDIT2: Another fiddle has been provided to demonstrate how both browsers initially show the same height values until calculating visible elements, where Chrome's calculations veer off track. http://jsfiddle.net/xjk8m8b1/2/

Answer №1

Despite not being the ideal solution, I managed to identify the problem. Firefox and IE both include the height of all elements within the div, including break tags and anything that adds vertical space. In my opinion, Chrome is flawed in this aspect as it fails to account for these additional elements! It does not provide an accurate measurement of consumed vertical space.

To work around this issue, I decided to enclose the contents of the div within another dummy div. This way, jquery considers the height of the first child div and accurately calculates the height.

Answer №2

Dealing with a similar issue where a ScrollBar was positioned in the middle and the StepContainer failed to adjust its height accordingly.

I managed to resolve it by making a slight modification in jquery.smartwizard.js:

$this.elmStepContainer.height(_step($this, selStep).outerHeight());

Changed it to:

$this.elmStepContainer.height(_step($this, selStep).outerHeight() +20);

Adding 20 did the trick for me, and the problem disappeared completely.

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

"Enhancing Your List Design: Customizing CSS for Hover Effects on Images

I'm currently working on a CSS/HTML list that utilizes an image as the background and changes to a different image when hovered over. However, I've encountered an issue where the hover image is not aligning properly, leaving a noticeable gap. T ...

A guide on implementing listings in React Native through the use of loops

I am trying to display the data retrieved from an API, but I am encountering an error. // Retrieving the data. componentWillMount() { tokenner() .then(responseJson => { const token = "Bearer " + responseJson.result.token; ...

Access the value of a JavaScript variable declared in one function within a separate function

Despite finding numerous posts on this topic, none of them suited my specific requirements. My goal is to utilize the seconddivval variable in the datepicker to display available dates. In my PHP code, I have a foreach loop with a hidden input: <td cl ...

Conceal the div element if the screen size drops below a certain threshold

Is it possible to hide a div element when the browser width is less than or equal to 1026px using CSS, like this: @media only screen and (min-width: 1140px) {}? If not, what are some alternative solutions? Additional information: When hiding the div eleme ...

Displaying a value in a React component using material-ui's TextField

Can anyone help me with printing the email a user enters into the textfield within the Dialog when a button is clicked? I have been struggling to achieve this due to my function's structure. Any guidance would be greatly appreciated. export default fu ...

Creating a dynamic dropdown menu based on a class value using JavaScript in PHP

There are two dropdown menus on my webpage that display information from my SQL table. The first dropdown contains different "Colors," and the second dropdown contains members associated with each color group. Each member is categorized into different optg ...

What can I do to keep my navbar on top of the slideshow?

https://i.sstatic.net/SfiLZ.jpg Is there a way to create a responsive navbar that sits in front of a slideshow containing images? I attempted to place the div within the main, but unfortunately it was unsuccessful. ...

How to convert a JSON response into a select box using VueJS?

I have a VueJS component where I need to populate a html select box with data from a JSON response. This is my VueJS method: getTaskList() { axios.get('/api/v1/tasklist').then(response => { this.taskList = this.data.taskList; ...

A pop-up window for selecting a file within an <a> tag

Is there a way to create an Open File dialog box on a link within my webpage? I attempted <input name="uploadedfile" type="file"> However, it only functions as a button and does not allow for the selection of multiple files. I would like somethin ...

Enhance your websites' search functionality with jQuery autocomplete using AJAX

I am attempting to implement dynamic autocomplete values for a text box. Here is my solution: echo json_encode($res) 0: {type_name: "name1"} 1: {type_name: "name2"} 2: {type_name: "name3"} 3: {type_name: "name4"} 4: {type_name: "name5"} Below is the co ...

What are some effective ways to resize the fontawesome glyph icon on my twitter-bootstrap website while maintaining proper alignment?

Are you able to figure out the code change needed on this under construction web page? There is a white box next to the company name at the top left, check it out here The site is twitter-bootstrap based with a white box "glyph icon" from FontAwesome. I&a ...

Is there a way to set the size of my unique carousel design?

Having some trouble with my modal image carousel; the dimensions keep shifting for different image sizes. Image 1 Image 2 ...

Tips for editing events in the "react-big-calendars" component

I am looking to implement a feature where users can click on events in a calendar and then edit either the dates or event titles. Can this functionality be achieved using "react-big-calendar"? If not, are there any other packages you can recommend? <Cal ...

The Angular router seems to be refusing to show my component

My Angular 2 App includes a Module called InformationPagesModule that contains two lazy load components (Info1 Component and Info2 Component). I would like these components to load when accessing the following routes in the browser: http://localhost:4200/ ...

Utilizing React and Material-UI to create an autocomplete feature for words within sentences that are not the first word

Looking to enable hashtag autocomplete on my webapp, where typing #h would display a menu with options like #hello, #hope, etc. Since I'm using material-ui extensively within the app, it would be convenient to utilize the autocomplete component for th ...

What are the steps for effectively utilizing the EmChart to achieve precise font sizes in ems?

Can you explain the intended use of this chart and instructions for how to utilize it? ...

What could be causing my C# function to not be triggered by AJAX?

I am attempting to invoke this specific C# method: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static string getJSONdata() { string jsonString = ""; using (SqlConnection con = new SqlConnection(conn ...

Utilize the UseQuery graphql function in conjunction with the useState hook within useEffect, allowing for the execution of an additional useEffect to update additional state

In my NextJS project, I am utilizing Apollo for graphQL queries and encountering an issue with the stateData.allProducts section. Despite setting the state in the useEffect and including data as a dependency in the array, the error claims it is null when d ...

Using Javascript to apply styling only to the first class element in the document

I am facing a challenge with styling programmatically generated classes and inputs. Here is an example of the structure: <div class="inputHolder"> <input type="button" class="inputclss" value="1"> </ ...

An interactive top navigation bar paired with three dynamic columns housing scrollable content, all crafted seamlessly with Bootstrap 4

I recently updated my layout using bootstrap but I am facing a glitch. I want the layout to have fixed scrolling only within the columns, without affecting the entire page. Everything works fine until I add some text inside any of the columns, then the who ...