What could be causing the erratic jumping behavior of the "newsletter sign-up" form within my modal dialog window?

On the homepage, there is a modal window that appears upon every pageload (it will be changed later), however, there seems to be an issue with the 'email sign up' form inside the window.

The form seems to momentarily display at the top of the site before quickly jumping inside the modal window where it belongs. This is not the desired behavior, as it should load inside the modal consistently.

Here are the settings for the modal:

<!--
Adjust the following values to customize the home page popup box.
-->
{% assign show_home_popup = 'true' %}

<!--
Setting this value to 'true' will only show the popup on the user's initial visit to the home page each day. If set to 'false', the popup will display every time the user visits the home page.
-->
{% assign show_on_first_visit_only = 'false' %}

<!--
Insert the direct link to the image you want to display in the popup between the quotes below.
-->

{% assign popup_image = 'https://dl.dropboxusercontent.com/s/2oac9b1j2cni7ta/JOINTHEPARTY.png' %}<!--
Set the maximum image width here if you want to adjust the size (e.g. assign image_width = '700'). The default width is 600 pixels if left empty (e.g. assign image_width = '' ).
-->
{% assign image_width = '450' %}

Here is the CSS for the modal:

 #homeModal {
    top: 150px;
    width: 450px;
    height: 400px;
    {% if image_width == blank %}
        max-width: 600px;
    {% else %}
        max-width: {{image_width}}px;
    {% endif %}
    right:0;
    left: 0;
    margin:auto;
    display:inline-block;
    padding: 0;
}



#homeModal img {
    width: 100%;
}
#homeModal iframe {
    position: relative;
    top: -193px;
    left: 25px;
}
 /*#homeModal iframe body,
  #homeModal iframe html
  {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
 } */

 @media screen and (max-width: 500px) 
 {
 #homeModal {
 height: 300px;
 width: 350px;
 min-width: 350px;
 }  
 #homeModal iframe {
 left: 1px;
 position: relative;
 top: -163px;
 }
 }

Here is the code/plugin/script for the modal:

  <link rel="stylesheet" href="http://googledrive.com/host/0B51UCH0yGk6FVkFBakNmUXVuREk/reveal.css">
  <script src="http://googledrive.com/host/0B51UCH0yGk6FVkFBakNmUXVuREk/jquery.reveal.js" type="text/javascript"></script>    
  <script src="http://googledrive.com/host/0B51UCH0yGk6FVkFBakNmUXVuREk/jquery.cookie.js" type="text/javascript"></script>    
  <script>
  $(document).ready(function(){
  $('#homeModal img').attr('src', '{{popup_image}}');

  {% if show_on_first_visit_only == 'true' %}
  if (!$.cookie("popup")) {
    //trigger your popup message
    $('#homeModal').reveal({
        animation: 'none',
        animationspeed: 300,
        closeonbackgroundclick: true,
        dismissmodalclass: 'close-reveal-modal' 
    });       

    //update the cookie after showing the popup
    $.cookie("popup","false", {expires: 1} ); //do not show again
}
{% else %}
    $('#homeModal').reveal({
        animation: 'none',
        animationspeed: 300,
        closeonbackgroundclick: true,
        dismissmodalclass: 'close-reveal-modal' 
    });       
{% endif %}

  });
  </script>

The issue can be seen here:

Answer №1

It seems like the problem could be related to how your CSS is loaded or the order in which it loads.

To recreate the issue, I tried adding the position as 'absolute' like this: https://i.sstatic.net/STqnu.png

One way to potentially fix this issue is by placing 'position: relative' at the beginning of your CSS file instead of at the end. This adjustment might help resolve the issue to some extent.

Please note that this solution may not make the content load inside the pop-up, but it could improve the loading time significantly.

Alternatively, you could consider embedding the entire pop-up as an iFrame containing the form for better loading performance.

Answer №2

The onload function for your form iframe appears to be set as follows:

window.parent.scrollTo(0,0)

This could be the reason for the sudden jump.

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

React: segregate state and functions away from the view, although encountering an excess of props to transmit

Experimenting with a new approach that keeps state definition and functions separate from components. For example: // Display.js const Display = (props) => { const { data, setData, action } = props; ... return <div>...</div>; } // Di ...

Determine if an HTML element contains a specific class using JavaScript

Is there a simple method to determine if an HTML element possesses a particular class? For instance: var item = document.getElementById('something'); if (item.classList.contains('car')) Remember, an element can have more than one clas ...

The duration of recorded audio in JavaScript is unclear

I managed to successfully create a structure for recording and downloading audio files. However, I'm facing an issue where the final downloaded file has an unknown duration. Is there any way to solve this problem?? Here is my Typescript code snippet: ...

What is the process for retrieving data from mongoDB and displaying it by year in a single row?

I have received an array of data from MongoDB, which includes id, userName, and date. The date consists of years and months. My goal is to display this data categorized by years. How can I construct a query to the database that will show the data for all y ...

What are the issues with the latest API routing in Next.js?

I am encountering an error that says: SyntaxError: Unexpected token s in JSON at position 0 Here is my code: import { PrismaClient } from '@prisma/client'; import { IDPay } from 'idpay'; import { NextResponse } from 'next/server&ap ...

Error encountered when parsing data: Found an unexpected token 'u' at the start position in the

I have been researching for quite some time now, but I am still unable to resolve the issue at hand. It seems like I am not the only one facing this problem. My current task involves fetching data from my controller using AJAX and integrating it into the ...

Is there a way to make Express JS always serve files from the current directory no matter the route?

Currently, I am developing an Express app utilizing the Handlebars template engine. The HTML files it serves have images that direct to specific locations in my root directory. Everything works seamlessly for basic routes like "http://localhost:5000/image" ...

Content located on the right-hand side of the menu

I am currently working on a vertical navigation menu design, but I am facing some issues with aligning the text to start from the very left edge of the element. HTML <div class="jobs-links"> <ul> <li><a href="renovations. ...

Jquery - Ajax: Error in Syntax JSON.parse: character not expected

I am encountering an issue with parsing JSON data on my client-side code. The JSON received from the server looks like this: [{"name":"Bubble Witch Saga 2","impressions":10749},{"name":"Grinder","impressions":11284},{"name":"Loovoo","impressions":12336},{" ...

The jQuery Deferred feature on Ajax is failing to properly pass the array in the data option as an array, instead converting

I am facing an issue in my application where I want to use jQuery deferred to handle Ajax success and error uniformly from a central location. It works perfectly fine when I pass strings in the data option, but when I try to pass an array, it gets sent as ...

Using Ajax (Jquery) to send data to a PHP script

Currently, I am working on an application where users can click a checkmark to complete a task. When this action is taken, a popup window appears (created using bootstrap), prompting the user to enter their hours worked on the task. After entering the hour ...

Issue with click function not activating in Chrome when using Angular 6

I am facing an issue where the (click) function is not triggering in my select tag when I use Google Chrome, but it works fine in Mozilla. Below is my code: <div class="col-xl-4 col-lg-9"> <select formControlName="deptId" class="form-control ...

The link in the navigation bar is not functioning correctly

Let me break down the issue I'm facing here. The problem arises with the navigation buttons that have sub-lists nested within them (ul>li>ul). When attempting to click on these buttons, the link does not work unless I specifically click on the t ...

The pop-up in the navigation bar imported from another source is malfunctioning

I'm in the process of constructing a website with a navigation bar that I'm importing from another HTML file, like this: Navbar HTML <nav class="navbar fixed-top navbar-expand-lg bg-dark navbar-dark"> <a class="navbar-brand" href="in ...

Modify the CSS of the gauge element without causing any issues

I am facing an issue while trying to resize this gauge element. Whenever I attempt to modify the container class to make it smaller, the entire gauge ends up distorting. Changing the position to relative seems to cause glitches at the edge of the gauge. An ...

Obtaining text from a select list using JQuery instead of retrieving the value

How can I retrieve the value from a select list using jQuery, as it seems to be returning the text within the options instead? Below is my simple code snippet: <select id="myselect"> <option selected="selected">All</option> <op ...

Scraping the web using Python for HTML data retrieval

I'm working on a Python program to retrieve the card sub-brand and brand based on a card BIN number. The URL for this information is: . The code snippet below fetches the card type from the page. page = requests.get('https://www.cardbinist.com/s ...

Using jQuery to locate the href attribute within a TD element with a specific

Update URL <td class="posts column-posts"><a href="edit.php?tshowcase-categories=ops&amp;post_type=tshowcase">2</a></td> Current URL: <span class="view"><a href="https://blog.company.com/team/tshowcase-categories/ops ...

Unable to retrieve the desired information from the jQuery AJAX request

Here is an example of a C# web method: [WebMethod] public string Greetings() { return "Greetings from the server"; } This is the jQuery AJAX code used to call the web method: $.ajax({ url: "http://10.0.2.2/SampleService/ ...

Do we need to duplicate structured data when listing nested objects, or is it better to avoid doing so?

We are currently focused on implementing JSON structured data for a one-page website that contains extensive information about a local business, including address, pricing, reviews, and services. The JSON snippet provided below represents the structured da ...