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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:38:19+00:00 2026-06-02T19:38:19+00:00

I started writing a very Simple jQuery Popup myself. Here is the code <script

  • 0

I started writing a very Simple jQuery Popup myself.

Here is the code

<script type="text/javascript">
 $(document).ready(function(){
    $("#pop").click(function(){
         openPopup();
    });
    $("#close").click(function(){
        closePopup();
    });
  });

function openPopup(){
$("#overlay_form").css({
    left: ($(window).width() - $('#overlay_form').width()) / 2,
    top: ($(window).width() - $('#overlay_form').width()) / 7,
    position:'absolute'
});

$("#overlay_form").fadeIn(1000);

   }
 function closePopup(){
$("#overlay_form").fadeOut(500);
}

$(window).bind('resize',openPopup);

</script>

Everything is working fine. But the problem is here in this code

   $(window).bind('resize',openPopup);

This code is to keep the popup in the center of the browser. But, even after i close the popup, if i resize the browser this code again opens up the popup.

I need to use a if condition somewhere in the code!. Where to use and how to use?.
Give me a solution please!.

  • 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-02T19:38:20+00:00Added an answer on June 2, 2026 at 7:38 pm

    Remove the .fadeIn() from the function and place it in the click handler.

    $("#pop").click(function(){
      $("#overlay_form").fadeIn(1000);
      resizePop();
    });
    
    
    function resizePop(){
      if(!$("#overlay_form").is(':visible')){
        return;
      } 
      $("#overlay_form").css({
          left: ($(window).width() - $('#overlay_form').width()) / 2,
          top: ($(window).width() - $('#overlay_form').width()) / 7,
          position:'absolute'
      });
    }
    
    $(window).bind('resize',resizePop);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a very simple script to control a process, script checks if the
I am very new (started today) to writing chrome extensions but need to write
I have just installed C# 2008 Express Edition 2008 and started writing code. My
I am trying to parse F# type syntax. I started writing an [F]Parsec grammar
I am writing a very simple RSS reader - all it needs to do
I started writing functional tests for my rails app today. I use the RESTful
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
Recently, I started writing a program to compare DNA sequence. As the alphabet only
I'm just getting started on writing functions instead of writing everything inline. Is this
I'm writing an application and started to test my domain model entities. If I

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.