Creating a Counter that increments by 1 every second [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
So I'm trying to make a counter that begins counting as soon as the page is loaded and continues indefinitely. Much like what's done on candies.aniwey.net the only difference is I'm using asp.net and was wondering how to do it and what's the most efficient way? ASP.Net, Javascripting, etc.
Thanks
-- Sorry yeah, in the browser. Should have been more specific.

try using the date or datetime class in asp.net (sorry i work java, android, i will use java code)
like java you can use Date class for time operation, like you want to do, for example when the page start loading take a timestamp of the current time, then when the visitor leave take another timestamp, do the math and voala you have the seconds that person that person stay in that page
in code:
Date startTime = new Date();
Date endTime = new Date(); --> this must be activate in a event of some sort
int seconds = endTime - startTime;
that is the idea

Where do you want the counting to be done? You say "as soon as the page is loaded" which sounds like you mean in the Browser.
In which case JavaScript.

Related

How can I edit javascript in a browser [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I'm trying to modify a webpage I access that has a table with a bunch of rows. I'd like to loop through and compare a name in that row with a name on another list I have, if it's there make that name in the table red. I don't have any code yet, but I'm lost when it comes to figuring out how to run this code when I run the webpage in my chrome browser. Does anyone have an example or tutorial about how to do this? Most posts on this topic are many years old and it's been hard to find this info. I appreciate your help!
It sounds like what you're trying to do is modify the structure of a webpage you don't own the code to. While you can use the developer tools to run arbitrary JS, that becomes tedious to do every single time.
I think what you want is a browser plugin. Check out the resources below:
Chrome: https://developer.chrome.com/extensions/getstarted
Firefox: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension
There may also be specific browser plugins already that let you run arbitrary JS code on certain pages, but I am not aware of any myself.

Value of a number going up [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Right, i honestly have no idea what to even search to find this out! i have searched many phrases trying to find out and i keep coming back with nothing.
I have a client who has asked if it is possible to have a number like 2.00000000 and have it constantly going up at a variable speed. The task he wants is to have is for different users to have a number that keeps going up (for what reason i don't know, i said ill look into it for him to find out if there is a plugin or something).
But either way he wants it to b able to even while the user is offline the value still continues to go up.
Is there such a plugin to achieve this? cheers
If it is at variable speed couldn't he just check the date time at which he initialize the sequence and compare it to the time at which he checks the number. The difference in time would be that offset he would call variable speed
For example if he wanted the number to increase 10 every 24 hours then:
double intialTimeInSeconds = //Whatever the Start time would be
double amountGainedEverySecond = 24/10/60/60;
double nowTime = //whatever time it is now;
return (nowTime - initialTimeInSeconds)*amountGainedEverySecond;

Implementing a "nag" counter for javascript cookies [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
First and foremost, hello everyone. I know that I am new, and I apologize for the fact that I have no prior contributions.
That said, I am a student at Rasmussen. I have an assignment in my JavaScript class that requires that I create a "nag" counter that will alert the user on their fifth visit that they should register. Then I must do this for every fifth visit until the user A) Gets annoyed and stops using my website, or B) they register. At that time, I have to delete the cookie that holds the counter and the "nag" and replace it with a landing page that welcomes the user back to the website, displaying their registration credentials.
I know that this can be done, I have seen it numerous time. The problem that I am having is the fact that I am so new to JavaScript that feel like I am in way over my head. I have spent about 2 hours combing through my textbook, as well as Google, and I have not found any answers. I have asked my Instructor and fellow students for help but have yet to receive any. Te last time my instructor advised me, she said "Try Googling it."
I do not even know where to begin this assignment. I appreciate any help you may or may not be able to offer. I am not looking for a handout, or for anyone to do my assignment for me. I assure you I am in fact trying to learn something, but I feel this assignment it too much.
When a user loads the page, read the cookie to see if it exist. If it doesn't, set count = 1.
Once a user fills in the text boxes and clicks the register button, delete the nag counter cookie and replace it with cookies containing the user's name and e-mail address.
If they don't register, the next time they load the page, set count = 2.
On every 3rd visit, implement the nag. (use logic/control flow statements to achieve this)

how to use php or js to record the stay time of user in my web site page? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how to use php or js to record the stay time of user in my web site page?
someone click a link and jump to my website page, he stay in the page for 5 seconds then close the page.
I want to record the 5 seconds to my database , how can I do the job using js or php?
it seems as the same as ga, but I don't know how ga do this.
You can use javascript's setInterval method to periodically send something to your server
For example:
setInterval(function(){
sendToServer()
},1000);

Javascript time spent playing [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How would I format the time being played by using a variable.
I need to store the current time spent playing by using a timer I would assume.
I will update the current time every-time paused is pressed.
How then would I format the variable into a readable format?
What is the best way to do all of this, what timers? How?
Your question doesn't give much details to help you.
But here are some links for javascript timers.
http://javascriptweblog.wordpress.com/2010/06/28/understanding-javascript-timers/
http://ejohn.org/blog/how-javascript-timers-work/
You may have a play/pause button. And trigger functions on pressing that button.
Try something using this information, when stuck in some problem, post what you tried, and people will help you.

Categories

Resources