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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:16:13+00:00 2026-05-15T05:16:13+00:00

I have a client who wants to open variously sized images in a centered

  • 0

I have a client who wants to open variously sized images in a centered popup. I tried to get them to use FancyBox but they don’t want interstitial presentation, so…

I initially was opening a generic popup which resized and centered onload based on image size but they don’t like the shift so I added a PHP script to echo the sizes and used jQuery to fetch the size info to feed into the pop up call.

But it appears the delay this causes is setting off all popup blockers.

Here is the JS

$("#portfolioBigPic").click(function () {
      var src = $("#portfolioBigPic").attr('src');
      var ar = src.split('/');
      var fname = ar.pop();
      fname = '/g/portfolio/clients/big/' + fname;

      $.get("imgsize.php", { i: fname}, function(data){
      var dim = data.split(",");
      popit(fname,dim[0],dim[1]);
  });
});

function popit(img,w,h) {
  var features = 'width='+w+',height='+h+', toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1,';
  var left = (screen.width/2)-(w/2);
  var top = 0;
  features += 'top='+top+',left='+left;
  bigpic = window.open('portfolioBigPic.php?img='+img, 'bigpic',features);
  bigpic.focus();
}

The only difference between dodging the blockers and failing is that I added the AJAX .get and use it to specify w and h.

Any thoughts on how to avoid this? Maybe I should use PHP to get widths and heights of all the big pics and write a JS array of them when this page loads? Am I right that the delay caused by fetching the data is tripping the blockers?

Thoughts? Any advice much appreciated.

JG

// EDIT – adding my resolution
Per Spiky’s answer I needed to move the popit() call out of the success handler for the AJAX call so that the call occurred in the context of the user’s click event.

So I realized that when my little thumbs are clicked to set the preview of the big image (#portfolioBigPic) I could look up the full sized pic at that point. So I moved the AJAX size look up to the click() for the thumbs.

HTH someone.

  • 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-15T05:16:14+00:00Added an answer on May 15, 2026 at 5:16 am

    It’s not the delay itself that’s causing the problem, it’s that you’re trying to open the window from a script execution context that is something other than a “click” handler. Specifically, in this case it’s the AJAX success handler (or whatever).

    You can’t work around that restriction, so yes you should dump your image sizes into the main page in the first place so that your script handling the “click” can know the sizes.

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

Sidebar

Related Questions

I have a client who requested piano keys as links and he wants them
I have a client who wants their app code signed, so we pointed them
I have a client who wants his script to be tweaked for some modifications.
I have a client who wants to offer options on the first page of
Okay, so I have a client who wants to output all information for a
I have a client who wants to transition off their old environment into .NET.
We have a client who wants us to extract data from their MS SQL
We have a client who wants us to prove that we have the right
We have a client who wants to build an app that essentially functions as
I have a client who wants to send gift certificates to people who sign

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.