presentation not visible at first

I'm facing an issue with adding a slideshow to the header of my website. When the page initially loads, the slides do not appear; instead, I see the dots and arrows positioned higher than they should be. However, when I click on a dot or the "next page" arrow, the images display correctly until I reach the end of the slides. At that point, the images disappear again, and the arrows and dots shift position. As a coding newbie who has been struggling for two days, I apologize for raising what may seem like a simple problem. I've searched for similar questions here but haven't found a solution yet, so any help would be greatly appreciated!

<script>
var slideIndex = 1;
showSlides(slideIndex);

function plusDivs(n) {
  showDivs(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("dot");
  if (n > slides.length) {slideIndex = 1}    
  if (n < 1) {slideIndex = slides.length}
  for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";  
  }
  for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block";  
  dots[slideIndex-1].className += " active";
}
</script>
...

Answer №1

If the disappearing act at the end and suddenly "popping up" seems to be happening, it could be due to 1) missing expected data (like an image in this scenario) and 2) as a result, the default stylesheet CSS is being applied (resulting in display:none;).

Upon reviewing your third slide, I observed the following code:

<div class="mySlides fade">
  <div class="towninfo">Caption Three</div><div class="towninfo2">dfvdfdfdfdfdfdfdf</div>
</div>

Instead of an image. Have you attempted replacing this with an image like the first two slides to check if it works correctly?

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

Anchor link leading to an incorrect location

Sorry for the potentially silly question, but I'm struggling to figure out what's happening here. I'm currently working on a website and trying to create an anchor link at . I've placed the anchor just before in this code: <a name ...

How can JavaScript be used to modify the locale of a web browser?

Is it possible to programmatically set the window.navigator.language using AngularJS? I am exploring different methods to achieve this. At the moment, I rely on a localization service to handle my i18n localization switching. ...

Error: SyntaxError encountered - JSON input unexpectedly ended

Below is a script that handles AJAX requests: var ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (JSON.parse(ajax.responseText).result == 'error') { console.log('error') $.each(JSON.parse(aja ...

Issue 404: Trouble sending form data from React to Express

I'm facing an issue when trying to send form data from a React frontend to my Node.js/Express backend. The problem seems to be related to a 404 error. I've included only the relevant code snippets below for reference. Function for submitting the ...

Adjusting the text color based on the dynamically set background color

If I have a calendar where each entry has a unique background color assigned to it (one color per user), including both light and dark colors that users can choose from, how can I set the text color to match the background style? Where should I begin wit ...

Cease the cropping function for Cropper.js when it extends beyond the boundaries of

Is there a way to prevent the crop corners from moving once the user drags the cursor out of the image while cropping? I encountered an issue where the cropped corners are displaced from the cursor when the user moves out of the image and then back in, wh ...

Waiting for the asynchronous fetch operation to finish in a webpacked application block

Currently, I am facing an issue where I need to block the fetching of an external JSON file so that a configuration object can be consumed elsewhere. This process involves three files: builder.jsx runtime.jsx and a JSON file: config.settings.json In t ...

Leverage the Power of AngularJS to Harness Local

I am currently developing an application using AngularJS. However, I have encountered an issue when trying to use localstorage. Here is my code snippet: var id = response.data[0].id; var email = response.data[0].email; localStorage.setItem('userId&ap ...

Using jQuery to dynamically disable a textbox when a checkbox is checked

I'm trying to implement a functionality where a textbox becomes disabled and changes its background color when a user unchecks a checkbox. Conversely, if the user checks the checkbox, the textbox should become editable and change its background color ...

Is it possible to align divs so that they touch when they wrap to a new line, creating a grid-like appearance?

My React board component consists of an array of divs that I want to arrange in a grid-like map. The issue is, when the div wraps to a new line, there is significant space between each row. I aim to have the divs close together with no gaps. GameMap state ...

Troubleshooting Problems with Cookie and Session Management

I'm encountering an issue while trying to set cookies and session values during login on the backend, which is built in node js. However, when react calls the API to verify these cookies or session values, they are returning as undefined... My middle ...

I'm struggling to make a div stretch across the full width of the screen

Despite my efforts, I can't seem to eliminate the noticeable margin between the div and the edges of the screen. <!DOCTYPE html> <html> <head> <title>Test2</title> <link rel="stylesheet" href="https://maxc ...

The Jquery UI confirmation dialog is working flawlessly on the Fiddle platform, but it is not displaying correctly on the

After testing this code snippet on a fiddle and seeing it work perfectly, I attempted to implement it on my website only to find that there is no border appearing, and the layout appears disorganized. Even after removing all the CSS styles and inspecting ...

Troubleshooting error handling in Node.js using Express and MongoDB

hey there, I'm new to Node.js and I'm working on creating a basic notes app using express and MongoDB. However, I'm encountering an issue when trying to update a note which displays "Cannot PUT" followed by the note's ID. Below is the ...

Is there a way to enclose a mention within a unique span tag after highlighting it? Similar to how tags are implemented on platforms such

Currently utilizing an AngularJS plugin called ment.io for incorporating mentions. However, I am having difficulty figuring out how to customize the appearance of the selected mention. For example, in Stackoverflow: https://i.sstatic.net/bZrkh.png Or i ...

Divs expanding below content in IE on a particular server

Currently, I am facing an issue with a JavaScript div that expands correctly over other content in most situations but goes under the content in one specific scenario. I am unsure about where to begin debugging this problem. To provide some context, the d ...

Unable to access Vue.js cookies: they are not defined

I integrated vue-cookies into my project successfully. In the main.js file, I added the following code: createApp(App) .use(store) .use(router, axios, VueCookies) The script section in App.vue file looks like this: <script> import Navbar fr ...

What are the steps to apply an AngularJS filter for formatting values within an array?

While I have experience using angular filters for formatting primitive values like numbers into currency formats, I am now faced with the challenge of applying the same filtering to an array of values. For example: price = 1 prices = [1,2,3] If I were to ...

Arranging two columns side by side for a particular set-up

I am trying to align two columns next to each other instead of stacking them on top of one another. I have adjusted the spacing to ensure there is enough room for them to sit side by side. I have included an image illustrating the positioning I am aiming f ...

JavaScript dialog on top of a flash video

I have a unique system in place: Upon opening the main site, a flash image gallery appears. When a user clicks on an image, I utilize Flash's "ExternalInterface.call" function to invoke a JavaScript function that opens a Java dialog modal called NyroM ...