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

  • Home
  • SEARCH
  • 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 6861745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:34:27+00:00 2026-05-27T02:34:27+00:00

I have next link that lets users navigate through a list of URL (stored

  • 0

I have next link that lets users navigate through a list of URL (stored in array). When a user clicks next, I want the link href and anchor to be updated for the next website in my array. The way I’ve tried so far, it link skips one URL each time, and I have and idea why, it has to do with the previous click even not completing, but what’s the right way to do this?

Here is an example so you can see exactly what I’m talking about: http://jsbin.com/atobep

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script>


$(document).ready(function(){

    var items = [];
    $.each(urls, function(i, item) {
        items.push("<li>"+item['name']+"</li>");
    });

    $('#list').append(items.join(''));

    changeNextLink(0);
    $("#frame").attr('src', urls[0]['url']);

});

var urls = [{"name":"ebay","url":"http://ebay.com"},{"name":"amazon","url":"http://amazon.com"},{"name":"msn","url":"http://msn.com"},{"name":"yahoo","url":"http://yahoo.com"},{"name":"wikipedia","url":"http://wikipedia.org"}];

function changeNextLink(x){     

    $('#now').html(urls[x]['name']); //show the name of currently loaded page
    $('#nextLink').html(urls[x+1]['name']); //name of next website as anchor of next link
    $('#nextLink').attr('href', urls[x+1]['url']); //url to next website
    $('#nextLink').attr('onclick','changeNextLink('+(x+1)+')'); //the problem spot. prepare next link for next click.

}
</script>
</head>
<body>

    <ol id="list"></ol>

    now: <span id="now"></span> | next: <a href="" target="frame" id="nextLink"></a><br />
    <iframe name="frame" src="" id="frame" style="width:500px; height:600px;"></iframe>

</body>
</html>
  • 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-27T02:34:28+00:00Added an answer on May 27, 2026 at 2:34 am

    How about adding a new var to keep track of the next link num, and adding a click handler for #nextLine:

    $(document).ready(function(){
        var nextLinkNum = 0;
        var items = [];
        $.each(urls, function(i, item) {
            items.push("<li>"+item['name']+"</li>");
        });
    
        $('#list').append(items.join(''));
    
        changeNextLink(nextLinkNum);
        $("#frame").attr('src', urls[0]['url']);
    
        $('#nextLink').click(function() { 
            if (nextLinkNum + 1 < urls.length)
                changeNextLink(++nextLinkNum); 
        });
    
    });
    
    function changeNextLink(x){     
        $('#now').html(urls[x]['name']); //show the name of currently loaded page
        $('#nextLink').html(urls[x+1]['name']); //name of next website as anchor of next link
        $('#nextLink').attr('href', urls[x+1]['url']); //url to next website
        $('#nextLink').attr('onclick','changeNextLink('+(x+1)+')'); //the problem spot. prepare next link for next click.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that when a user clicks on a link Add Comment,
I have this line below that shows a link to go the next page
I have a script that lets you put a link at the bottom of
I have a photo gallery that has a previous and a Next link. When
I'm going to start of by noting that I have next to no python
I have the next query that I run via SQLCMD.EXE use [AxDWH_Central_Reporting] GO EXEC
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
i'm trying to do something that is described briefly on the next link: link
I´m pretty profane in javascript. I need a previous and next link that will
I have some code that uses dispatchEvent to simulate clicks and the same exact

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.