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 7724427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:41:12+00:00 2026-06-01T04:41:12+00:00

Having a slight Javascript issue at the moment, I am hoping to have the

  • 0

Having a slight Javascript issue at the moment, I am hoping to have the below image have a variable HREF which is triggered by a time change.

At the moment it is triggering to some extent but then getting stuck on one of the URLs. It is also affecting an image which is overlaid on top of this one. Which isn’t the aim at all!

Any help would be great. Thanks.

<div style="position: absolute; left: 0; top: 0; z-index: 100"><a href="[VARIABLE     URL]"><img src="[BACKGROUNDIMAGE]" style="position: absolute top: 0; left: 0;"/></a></div>

<script type="text/JavaScript">

setTimeout(hyperlink1,3000);
setTimeout(hyperlink2,3000); 
setTimeout(hyperlink3,3000);

function hyperlink1 () {
$("a").attr("href", "[URL1]")
}

function hyperlink2 () {
$("a").attr("href", "[URL2]")
}

function hyperlink3 () {
$("a").attr("href", "[URL3]")
}

</script>
  • 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-06-01T04:41:13+00:00Added an answer on June 1, 2026 at 4:41 am

    Your selector, "a", will match all a elements on the page. That means all three of your functions, all of which are fired after roughly three seconds, will change all of the links to the same URL.

    You need to have each selector be specific to the link it’s going to change. You can do that with ids on the links, or by their (original) href, or using a class, etc.

    Also note that all three of your functions are being fired at almost exactly the same time. If that’s your goal, just use a single function to do all the updates. If your goal is to have one fire, then the next, then the next, either chain them:

    setTimeout(hyperlink1,3000);
    
    function hyperlink1 () {
        $("a").attr("href", "[URL1]")
        setTimeout(hyperlink2,3000); 
    }
    
    function hyperlink2 () {
        $("a").attr("href", "[URL2]")
        setTimeout(hyperlink3,3000);
    }
    
    function hyperlink3 () {
        $("a").attr("href", "[URL3]")
    }
    

    …or use a single function which walks through an array. It depends on how complex the real functions will be and whether you’re trying to repeatedly update just one link, or update a series of links one at a time.

    If you have just the one link, and you’re just trying to update it repeatedly, you might just walk an array like this:

    function update() {
        var index = 0,
            urls = [
              "/path/to/first",
              "/path/to/second",
              "/path/to/third"
            ];
         setTimeout(tick, 3000);
    
         function tick() {
             var href = urls[index++];
             if (href) {
                 $("a").attr("href", href);
                 if (index < urls.length) {
                     setTimeout(tick, 3000);
                 }
             }
         }
    }
    update();
    

    …but if it’s really just the three you’ve listed, well, the three functions chained via setTimeout is concise and clear. Concise and clear are Good Things(tm).

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

Sidebar

Related Questions

I am new to JavaScript and having a slight issue figuring out when events
I'm having a slight issue with ActionScript 3 and I have come here to
I have the two images below. They are the same image, with one having
Having a slight problem on C#, still quite new to the language but hoping
I have set up REST for my CakePHP and I'm having a slight problem.
I'm having a problem displaying an image in an image view, which is generated
having a slight issue where i am rendering a pdf (stored as a byte
I'm having a slight problem. I have set my <input type=file> to onChange=this.form.submit() .
I am having a slight issue sending formCollection data to my controller action method
I am having a slight performance issue with inline function. Consider the following code:-

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.