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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:46:00+00:00 2026-05-22T11:46:00+00:00

I am confused with this Javascript behaviour. Check this code. var NoOfMonthsElapsed = 6;

  • 0

I am confused with this Javascript behaviour. Check this code.

var NoOfMonthsElapsed = 6; //Should be >= 1 and <= 12
var MsgURL = "about:blank";
var PopupTitle = "ContactInfoUpdate";
var OptionString = "height=165,width=400,menubar=0,toolbar=0,location=1,status=0,resizable=0,status=0,HAlign=center,top=300";

var lastUpdatedDate = crmForm.all.dxb_lastcontactinfoupdatedon.DataValue; //Reads a field with date value = 01 Jan 2010
if (lastUpdatedDate)
{
  var month = lastUpdatedDate.getMonth();
  var year  = lastUpdatedDate.getYear();
  var date  = lastUpdatedDate.getDate();

  month = month + NoOfMonthsElapsed;
  year  = year  + parseInt(month / 11);
  month = (month % 11);

  var today = new Date();
  var showPopupAfterDate = new Date();

  showPopupAfterDate.setYear(year);
  showPopupAfterDate.setMonth(month);

  var alertMsg  = "LastUpdatedDate          = "+ lastUpdatedDate + "\n"
  var alertMsg += "Today                    = "+ today + "\n"
  var alertMsg += "PopupAfterDate           = "+ showPopupAfterDate + "\n"
  var alertMsg += "Today>showPopupAfterDate = "+ (today>showPopupAfterDate) + "\n"

  alert(alertMsg);

  if (today>showPopupAfterDate); 
  {
    window.open(MsgURL, PopupTitle, OptionString);
  }
}
else 
{
  window.open(MsgURL, PopupTitle, OptionString);
}




//
// It displays the following output
//
LastUpdatedDate          = Wed May 18 20:56:00 UTC+0400 2011
Today                    = Fri May 18 20:23:49 UTC+0400 2011
PopupAfterDate           = Fri Nov 18 20:23:49 UTC+0400 2011
Today>showPopupAfterDate = false

Why today is shown as Fri May 18 2011… though May 18 2011 is Wed
Why PopupAfterDate is shown as Fri Nov 18 2011…
And Even though the dates comparission returns false; The window.open still get executed.

  • 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-22T11:46:00+00:00Added an answer on May 22, 2026 at 11:46 am

    Found the issue:

      if (today>showPopupAfterDate) //<-- remove the `;`
      {
        window.open(MsgURL, PopupTitle, OptionString);
      }
    

    Your code is running the if, stopping, then doing the next statement which is the window.open

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

Sidebar

Related Questions

I'm confused about this. Most of us have been told that there isn't any
I am a bit confused why this code compiles. I leave out the necessary
I am a little confused by this snippet of code (presented in the CocoaFundamentals
I am a bit confused about this. If you're building a distributed application, which
I can't believe I'm still confused about this but, any way, lets finally nail
I'm learning C++ and I'm still confused about this. What are the implications of
I'm very confused with JavaScript methods defined in objects and the this keyword. In
I'm new to Javascript and am confused about the error messages I get: I
I have a question in JavaScript context. I'm a little confused by this issue.
I'm a little confused about this. Titanium is bragging about being able to style

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.