The animation in jQuery is triggered to start as soon as the page loads, but in Internet Explorer, it waits until the

Upon loading my page, a jQuery animation should start automatically. Here's the code snippet responsible:

function repeatscroll() {
    if ($('div#photoscroll img').css('margin-left') == '0px') {
        var margin = '-770px';
    } else {
        var margin = '0px';
    }
    $('div#photoscroll img').animate({'margin-left': margin}, 20000, 'linear', function() {repeatscroll();});
}

$(document).ready(function() {alert('in');repeatscroll();});

This script effectively scrolls through a series of images stored in a long strip from right to left and then back again.
It is triggered by $(document).ready().

Unfortunately, this functionality works seamlessly on non-IE browsers. However, there seems to be an issue with Internet Explorer.

When the page loads in IE, the alert('in') prompt displays instantly. However, the repeatscroll() function doesn't kick in until exactly 20000 milliseconds later, which matches the duration set for the animation. I verified that repeatscroll() isn't being invoked promptly by adding an alert line at the beginning of the function, which only triggers after the delay.

Check out this jsFiddle example

Why does IE postpone the start of the animation and what can be done to rectify it?

Answer №1

When using IE8 and earlier versions, the following code snippet behaves differently:

$('div#photoscroll img').css('margin-left')

Initially returns auto, while in other browsers (including IE9), it returns 0px as anticipated.

To address this issue, you can include the following CSS rule:

#photoscroll img {
    margin: 0
}

Check out: http://jsfiddle.net/XJu3W/1/

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

Using jQuery and regular expressions to replace placeholders with dynamic values

I need some help with replacing custom variable tags in a content block using values from an array. Currently, my code successfully replaces variables that look like %([variable_name])%, but I also need it to replace variables in the format <%[variable_ ...

Anticipate that the function parameter will correspond to a key within an object containing variable properties

As I develop a multi-language application, my goal is to create a strict and simple typing system. The code that I am currently using is as follows: //=== Inside my Hook: ===// interface ITranslation { [key:string]:[string, string] } const useTranslato ...

What is the best way to run JavaScript using nodriver in Python?

I'm currently facing some roadblocks while writing Python code. To elaborate, I've successfully logged into a site protected by Cloudflare using nodriver, and have been able to display the values of elements on the page. However, my ultimate obje ...

Refreshing a Next.js website on-demand using the Django model's save function

My current setup involves a next.js website deployed on Vercel, which retrieves data from an API provided by Django. Utilizing a new feature in Next.js known as Incremental Static Regeneration On-Demand, I am able to rebuild specific pages without having t ...

Tips for concealing a column within a jqgrid subgrid

Is there a way to conceal a column within a subgrid? Many thanks! ...

The functionality of cloning in jQuery may encounter an issue where the text field remains enabled if the user selects an option labeled "other

Currently, I am working on a jQuery clone with my existing code and everything is functioning well. In the first scenario, if the user selects other from the dropdown menu, the text field becomes enabled. In the second scenario, when the user clicks ...

Error: The variable 'err' is not declared in this scope.at line app.post

Tools I am Using Windows 10 Firebase (Firestore) Postman JavaScript, Express I'm learning from this video(https://www.youtube.com/watch?v=-vo7cu0xP4I) Situation Description I attempted to make a post request using Postman for testing purposes, b ...

What is the best way to position three divs next to each other in a row?

I have three divs with widths of 200px, 300px, and 200px. How can I align them side by side? Most examples only show how to do this with two divs. Div1 and Div2 are working correctly, but for some reason, Div3 is sliding under Div1 like in the picture belo ...

Code in JavaScript that shows only a portion of the selected option in a dropdown menu

I'm just starting to learn Javascript and I'm looking to create a script for a select tag that displays countries and their phone codes. My goal is to have the dropdown menu show both the country and code, but once the user selects an option, onl ...

Finding the identifier of a dynamically generated text input using PHP

I am looking to create a page similar to this On this page, users can add multiple entries for date, site, start time, end time, and hours amount by clicking the + button, and remove entries using the - button. How can I retrieve the input values in PHP? ...

Bootstrap 4 does not have the capability to include spacing between two columns

I'm encountering an issue with adding a gutter between 2 columns on my website layout. I have a row that needs to be 1280px wide (based on a reference resolution of 1366x768 with padding of 43px on each side of the page), containing two sections that ...

Unresolved peer dependency issue in NPM recursion

I'm attempting to enhance my @ionic-native/core in order to facilitate the installation of an OIDC client. Regardless of the commands I've attempted, I consistently encounter an error: UNMET PEER DEPENDENCY @ionic-native/[email protected] ...

Changing badge colors dynamically in Bootstrap

I'm currently working on a simple web application using Django and Bootstrap 4.5. Within one of my models, there is a color attribute that I would like to visually represent using Bootstrap's badge. My goal is to dynamically set the badge's ...

Nested modal in native app utilizes the React Carbon TextInput component for an uneditable input field

As a newcomer to React, I have encountered an issue with the Tauri framework used to bundle my React application as a desktop app. Specifically, I am facing a problem where the TextInput field, nested inside a modal and utilizing React Carbon components, i ...

Exploring the intricacies of XML embedded within JSON

Utilizing YQL for jQuery, I am able to successfully execute cross-domain REST requests. The JSON response contains the desired XML data as key-value pairs. The specific request being made is: http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%2 ...

Why won't Handlebars show the HTML image tag? (with NodeJS)

I'm having trouble displaying an image using handlebars in HTML. The HTML code is being correctly passed to handlebars and then to the webpage, but the image itself is not showing up. How can I resolve this issue? Here is a snippet from my .HBS file: ...

The auto-complete feature on Yahoo search occasionally displays outdated search suggestions

When using Yahoo Autocomplete with a remote php database request and zero time delay, I sometimes encounter the issue of old query results coming back after the most recent query. For example, if I search for "beginner", the results from "beg" may override ...

Utilizing JSON with multiple partial views

I'm planning to rephrase this inquiry in a slightly revised manner. Let's suppose there are 2 or more instances of the [same] partial view appearing on the page. Within this PartialView, you'll find a text box and a button. Upon clicking ...

What is the method for deactivating an option with multiple values that are separated by commas?

I am working with a unique situation where I have options that contain multiple values $('#addItemModal #servicesBlock select[name=service_id] option[value='+service.val()+']').prop('disabled', true); <script src="https: ...

Tips for passing data to a child component from a computed property

Currently in the process of setting up a filter using vue-multiselect. Everything seems to be working fine, but there's one issue I can't seem to resolve. Upon page reload, the label (v-model) appears empty. The root cause seems to be that the v ...