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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:18:44+00:00 2026-05-17T16:18:44+00:00

function dlLink(title, currentArray, currentIndex, currentOpts) { var img = new Image(); img.src = ‘Gallery/Wallpapers/’

  • 0
function dlLink(title, currentArray, currentIndex, currentOpts) 
    {
        var img = new Image();
        img.src = 'Gallery/Wallpapers/' + title;
        html = img.width + ' x ' + img.height + '<br />'
                + '<a class = "nav" href = "Gallery/Wallpapers/' + title + '" target = "_blank">Download</a><br />http://';

        // set up default options
        var defaults = {
            login:      '*************',
            apiKey:     '*******************************',
            longUrl:    'http%3A%2F%2Fschnell.dreamhosters.com%2Fwallpapers.php%3Fwp=' + title
        };

        // Build the URL to query
        var daurl = "http://api.bit.ly/v3/shorten?"
                    + "&login=" + defaults.login
                    + "&apiKey=" + defaults.apiKey
                    + "&longUrl=" + defaults.longUrl
                    + "&format=json&callback=?";

        // Utilize the bit.ly API
        $.getJSON(daurl, function(results)  {
            $('#fancybox-title').append(results.data["url"].substr(7));
        });

        if(img.complete)
            return html;
    }

Ok, the point of this function is that it’s a callback to a Fancybox that puts HTML content into it’s ‘title’ section. In this section I put the image’s resolution, a download link and a bit.ly link for coming back to the image at this website – http://schnell.dreamhosters.com/wallpapers.php?page=12 Originally I was having XMLHTTPRequest problems with the bit.ly URL, but I seem to have resolved those.

The problem now, though, is that I need the variable ‘html’ to have all the html content that’s going into the fancybox before the return statement comes up. While it may look like everything happens before the return statement, jQuery is doing the $.getJSON() function asynchronosly and so it’s not garaunteed that ‘html’ will have stuff in it before dlLink ends. I need a way to make it so that the order of things happens as its shown in the code, so that the $.getJSON request and the subsequent callback function will always finish what they’re doing before going onto the return statement.

Edit – I figured out what to do and the code above correctly does as I wanted. See my answer below.

  • 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-17T16:18:44+00:00Added an answer on May 17, 2026 at 4:18 pm

    Ok, so I finally solved this after realizing a few things.

    1 – You’re kinda supposed to do all the work you can with the JSON data while in the callback function of $.getJSON().

    2 – The area I was trying to put the link in had the id ‘fancybox-title’, so I just went ahead and said $('#fancybox-title').append(stuff);

    3 – Fancybox’s title (when shown on the inside at least) will only size itself for lines of text that are already there by the time the function formatting the title has finished. Anything appended to it after won’t be accounted for in size and so the title area will remain the same and you’ll see lines of text creep up into the picture (found this out the hard way). To get around this I made sure to add a 3rd line of text to my ‘html’ variable – <br />http:// This made Fancybox size its title area for 3 lines of text. Then in the callback function I used substr to take the bit.ly link starting from after http:// and to the end.

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

Sidebar

Related Questions

function loaded() { document.addEventListener('touchmove', function(e){ e.preventDefault(); }); myScroll = new iScroll('scroller'); } document.addEventListener('DOMContentLoaded', loaded);
Function Edit(ByVal id As Integer) As ActionResult Dim entities As New Deployment_devEntities() Dim w
function ExChgClsName(Obj,NameA,NameB){ var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj; Obj.className=Obj.className==NameA?NameB:NameA; } <a href=javascript:showMenu(2);> i am a newbie of the
function validateRequiredFields(formid) { var inputs = document.getElementsByClassName('required'); for(i=0;i<inputs.length;i++) { var FieldID = inputs[i].id; if(
function selected() { var selObj = window.getSelection(); } This function returns selected text from
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function main() { Hello(); } function Hello() { // How do you find out
function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError,

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.