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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:02:06+00:00 2026-06-08T03:02:06+00:00

I have a below anchor as below <a onclick=return getFile(‘/log/sample.log’); href=/log/sample.log target=_blank> sample.log </a>

  • 0

I have a below anchor as below

<a onclick="return getFile('/log/sample.log');" href="/log/sample.log" target="_blank"> sample.log </a>

Because at my server, the log directory in href may be not correct. So the function “getFile” would change the href to the correct one after asking the server.

The first click always failed since the link was not correct, then after AJAX process in getFile was finished and the correct href was given, the clicks later on was ok.

The problem is how I forcefully let html wait ever at the first click until the href is changed, then do the query on the server.

Thanks in advance.

I guess my current way could be not in the correct direction by using “onclick” to implement the idea.

  • 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-08T03:02:09+00:00Added an answer on June 8, 2026 at 3:02 am

    You want something like this

    $(function() {
    
    //assume you tagged all anchors you want to do this for with class=adjustlink
    $('a.adjustlink').click(function(e) {
      var thisAnchor = $(this); //save reference for later use
    
      //this will either be true (see below) or undefined (falsy)
      if(thisAnchor.data('myapp.linkHasBeenTested')) {
        return;  //continue on
      } 
    
       // Stop the link from being navigated (the default for this event)
       e.preventDefault();
    
      //I'm assuming this is fetched as text but could just as well be JSON or anything else
      $.get('/LinkAdjustment/', thisAnchor.attr('href')).done(function(result) {
        thisAnchor.attr('href', result); //set the href
        thisAnchor.data('myapp.linkHasBeenTested', true);
        thisAnchor.trigger('click');
      });
    });
    
    });
    

    As an interesting side-note. You might be attempting to do something similar to the way REST is intended to be done. You might consider, first fetching a resource that will tell you up-front what the correct links are.

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

Sidebar

Related Questions

I have several such anchor links as shown below. <a href=http://google.com onClick=unhook()> Google </a>
I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I
I have a link with 'remove' anchor text with href something like below: ./index.php?del_id=5
I have an anchor tag setup like below <a href='' title='' class='video-author-box hoverbox'> <img
See the code/HTML snipped below. I have an anchor with an href which is
I have below structure <div class=mybox> <div id=imageslide> <a href=><img src=url /></a> </div> </div>
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have below sample data. AID Date Title ----- ---------- ------ 1 2011-12-12 test1
I have below html code in my aspx. <input type=hidden id=medicalLink value='<a href=/forms/contactus.aspx >Contact
I have numerous link in my View, which are shown like below retailerName1----------info----------anchor-Link-retailer1 retailerName2----------info----------anchor-Link-retailer2

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.