I don't know javascript but have searched google for hours until I found daniweb, and so I thought I would ask experts. I want to be able to display a message for first time visitors to a website. Ideally it would check to see if they've been to the page before and if not, then the message would offer a premium if they acted immediately. But, the message would say something like, "If you buy before hrs:mins you can use coupon code xyz123 for 10% off" or words to that effect.

I would like the message to use their computer's time and add 30 minutes so that if the new user visits the site at 12:00 noon, the message would read, "if you buy before 12:30PM...", instead of just "buy now" or "buy in the next 30 minutes".

I just can't figure out how to put javascript in javascript. And, hopefully, make it work across IE and Firefox.

Thank you in advance...

Recommended Answers

All 7 Replies

Member Avatar

Use jQuery.
Look into the DateTime object
Use JavaScript cookies.

If you want an offer only once, you need the server side database. Cookies can be tampered and/or delete. You will be offering special price all the time if you use cookies.

I realize that I may be offering the discount more than once, which is okay. I know cookies can be deleted and that's fine. Actually, if there are some who know to do that, they may feel like they're getting something for nothing which is also fine.

I have no idea what jquery is and have only used databases when someone else set them up. I really just want to have something simple and it's fine if everyone uses the discount, it's really just to create a call to action.

Thank you for posting!

JQuery is a JavaScript library which hides the original (pure) JavaScript implementation into its own format. You could accomplish the same job using either the library or pure JavaScript. If you do not know about JQuery, their website is If you want to create it using pure JavaScript, you may learn how to create Cookies at Then use the cookies to check whether the client has visited your site before.

Member Avatar

JQuery is a JavaScript library which hides the original (pure) JavaScript implementation into its own format.

I'm sorry, but I don't think this statement is accurate at all. JQuery is a library, plain and simple. The reason why people find it to be so different from the way they are used to writing JavaScript is because it is written properly. It hides nothing. It does not have it's own implementation of JavaScript.

Well thanks everyone. Obviously I'm in the wrong place so apologies for taking up your time. Was looking more for coding help where as this appears to be more shop-talk. I'll pick up google search where I left off but wanted to say thanks to those who commented.

Member Avatar

We are here to help with coding, but you didn't show any code. We aren't going to write things for you, but we can always point you in the right direction and I believe we've done this. Use JavaScript, cookies and look into jQuery. - look at the Browser Scripting section

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.