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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:04:37+00:00 2026-05-23T04:04:37+00:00

This should be a really easy derp question, but here it is: I’m trying

  • 0

This should be a really easy “derp” question, but here it is:

I’m trying to set up a global variable in a JS file so that I can control when an action triggers. In my case, I want okBoxCall to only be called if firstTime is true. I have firstTime set to true initially, then I change it to false afterwards. My code is NOT working as it should however, as it still calls up okBoxCall more than once.

var Dialog;
var HUDWindow;
var smartPhone;
var firstTime = true;


$(document).ready(function(){
   smartPhone = new SmartPhone();
   initDialog();
   initHUDWindow(); 

   if(firstTime == true)
   {
       okBoxCall("Tutorial", "Welcome to McLarin Energy!");
       firstTime = false;
   }
});

What am I doing wrong? Obviously firstTime is not holding its change to false…

EDIT Forgot to mention that this is for a 3D game, not web pages. Cookies are not used.

  • 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-23T04:04:38+00:00Added an answer on May 23, 2026 at 4:04 am

    I’m guessing you want to check whether this is the first time the user opens a page and open a tutorial if it is?

    It is not possible the way you want to do it. Every time your page is loaded your script is evaluated again. So this means a variable firstTime is created and it is set to true. What you need is some persistent storage on the client to store whether it is the first time or not. You will need to set a cookie or call the localStorage API if you don’t bother disregarding older browsers.

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

Sidebar

Related Questions

This should be really easy but I am struggling. Here is my current code
This is probably a really easy question, but I can't find anything that works.
Ok, this should be really easy, but I just don't have enough experience. I
This should be an easy question I figure, but I hadn't found this answered
This should be really easy but for some reason it doesn't seem to be.
This should be really easy, but I'm just not seeing how to do it.
This really should be easy, but I just can't work it out myself, the
this should be an easy one and I really thought that what I was
This should be really easy but I can't figure out how to make it
This feels like it should be really easy, but I just can't get it

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.