Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7612853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:01:15+00:00 2026-05-31T02:01:15+00:00

I need to redirect a page when an image slider reaches the last image

  • 0

I need to redirect a page when an image slider reaches the last image (ideally after a set time).

I have the code below sort of working but it redirects as soon as the second image is shown. Can anyone help please?

if ($('#mainContent ul.introScreen li img.active:last').css('display', 'block')) {
    window.location.href = "/ibp/app.php";
} else {
    //Do nothing
}

Thanks folks.

EDIT: I think I have an issue with my code somewhere, it seems to be cycling through just the first image. My code is below. Any idea?

function slideSwitch() {
    var $active = $('#introScreen li img.active');
    if ($active.length == 0)
        $active = $('#introScreen li img:last');
    var $next = $active.next().length ? $active.next() : $('#introScreen li img:first');
    $active.addClass('last-active');
    $next.css({
        opacity: 0.0
    }).addClass('active').animate({
        opacity: 1.0
    }, 1000, function () {
        $active.removeClass('active lastActive');
    });
    if ($('#introScreen li img.active:last').is(':visible')) {
        setTimeout(function () {
            window.location.href = "/ibp/app.php";
        }, 1000);
        // 1 sec
    }
}
$(function () {
    setInterval("slideSwitch()", 5000);
});

EDIT: I’m trying a different approach using the Cycle jQuery plugin with the following code:

HTML:

<div id="introScreen">
    <ul id="slides">
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
        <li><img src="images/screen01-placeholder.png" alt="Screen 01 Placeholder" /></li>
    </ul>
</div>

jQuery:

$("ul#slides").cycle({
    fx: 'fade',
    pause: 2
});
if ($('ul#slides li:last').is(':visible')) {
    setTimeout(function () {
        window.location.href = "/ibp/app.php";
    }, 1000);
    // 1 sec
}

Now the images fade in to each other fine but again now the page does not redirect? Any ideas guys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:01:16+00:00Added an answer on May 31, 2026 at 2:01 am

    Use is(":visible") to check whether the element is visible or not:

    if($('...:last').is(':visible')) {
    ...
    }
    

    Another variant:

    if($('...:last:visible').length /* == 1 */) {
    ...
    }
    

    I’ve removed all selectors except the ones that matter. I would rather place the logic in the code that changes the slides.

    Edit 2

    jQuery.cycle plugin fires various events. One of them is the after event that fires after a slide is displayed. Within that event you can check if it was the last slide and do whatever is necessary:

    $("ul#slides").cycle({
        fx: 'fade',
        after: function() {
            if ($(this).next().length === 0) {
                alert("Place the redirection code here");
            }
        }
    });
    

    Demo here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to do some image manipulation (that could take long time) after page
What we need: redirect to each user's specific page after their login. What we
I need to redirect all page requests (php, if that matters) on a specific
I need to redirect user to another page called free.php from index page, if
I need to redirect users to the Change Password page if their password has
I need to redirect the user to page not found page if the url
I need to redirect a user to a different page if they visit a
I need some advice on techniques to perform page redirect in asp.net. Which one
I need to create a landing page that will automatically redirect a visitor to
I use the following example Redirect to redirect to a page. What i need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.