Hello,
I am by no means a person who is remotely proficient in javascript. I’ll do my best to stay within what is acceptable for a post here.
We purchased a javascript counter, and yes I did contact the author of the code and he has helped some, but I have not been able to get a response from him for about 2 weeks, so I am kind of at a loss for what to try.
We, the company I work for, have a webpage up that has daily specials that change every 24hrs. Here is the link: [url]http://www.grimco.com/InfoPages/daily_deal/daily_deal.aspx
Every night at midnight central time the div “any_html” updates to show new content, etc. That part works just fine. As you can see on the page, there is a counter that counts down the time left on the special, which also works just fine. The issue we’re having is that if someone viewing the page either has the incorrect date, or changes their date on their computer they can see what specials are going to be coming up. I’m trying to find a way to stop them from being able to do that (if that is possible). I thought about just updating the page everyday before I leave with new code, but figure there should be an easier way. Here is the code that we are using on that page
[CODE]<script type=”text/javascript”>
var myCounter = null;
var timerId = null;
var destTime = null;
var rotatedImages = [
{ html: ‘<div style=”background-image:url(deal_statement.png); height:388px; width:900px”> <div style=”width:626px; height:239px; margin:95px 0px 0px 255px”><a href=”http://twitter.com/#!/GrimcoDailyDeal”><img src=”deal_statement_1.png” border=”0″ alt=”Deal of the Day”/></a></div></div>’, dateFrom: new Date(2011, 07, 02, 24, 0, 0), dateTo: new Date(2011, 07, 07, 24, 0, 0) },
{ html: ‘<div style=”background-image:url(deal1_background.png); height:388px; width:900px”> <div style=”width:626px; height:239px; margin:95px 0px 0px 255px”><a href=”../../Products.aspx?cid=0003&pid=00022″><img src=”deal1.png” border=”0″ alt=”Deal of the Day”/></a></div></div>’, dateFrom: new Date(2011, 07, 07, 24, 0, 0), dateTo: new Date(2011, 07, 08, 24, 0, 0) },];
function loadCounter() {
myCounter = [
new Counter(“my_counter_1”,
{digitsNumber: 2,
direction: Counter.ScrollDirection.Downwards,
characterSet: Counter.DefaultCharacterSets.numericUp,
charsImageUrl: “images/numeric_up_redbg5.png”,
markerImageUrl: “marker.png”,
extraClassName: {left: “ex1_left”,
right: “ex1_right”,
inner: “ex1_inner”}}),
new Counter(“my_counter_2”,
{digitsNumber: 2,
direction: Counter.ScrollDirection.Downwards,
characterSet: Counter.DefaultCharacterSets.numericUp,
charsImageUrl: “images/numeric_up_redbg5.png”,
markerImageUrl: “marker.png”,
extraClassName: {left: “ex1_left”,
right: “ex1_right”,
inner: “ex1_inner”}}),
new Counter(“my_counter_3”,
{digitsNumber: 2,
direction: Counter.ScrollDirection.Downwards,
characterSet: Counter.DefaultCharacterSets.numericUp,
charsImageUrl: “images/numeric_up_redbg5.png”,
markerImageUrl: “marker.png”,
extraClassName: {left: “ex1_left”,
right: “ex1_right”,
inner: “ex1_inner”}})];
timerId = window.setInterval(function () {
var i = 0;
var now = new Date();
if (destTime == null){
for (i = 0; i < rotatedImages.length; i++)
if (now >= rotatedImages[i].dateFrom && now < rotatedImages[i].dateTo){
destTime = rotatedImages[i].dateTo;
document.getElementById(‘any_html’).innerHTML = rotatedImages[i].html;
break;
}
}
var diff = Math.floor((destTime – now) / 1000);
if (diff <= 0)
destTime = null;
myCounter[0].setValue(Math.floor(diff / 3600 % 99), 800);
myCounter[1].setValue(Math.floor(diff / 60 % 60), 800);
myCounter[2].setValue(diff % 60, 800);
}, 1000);
}
loadCounter();
</script>
This code all works, I just need to figure out how to stop visitors from updating their date/time to see future specials.
I had a friend, who knows a little bit about javascript suggest adding this code:
[CODE]now.setTime(<% Response.Write( ((long)(DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds)).ToString() ); %>);
under the line that reads:
[CODE]var now = new Date();
I did try that but when I do I get a syntax error and the page no longer works, so I took it out. Sorry if this is way too long but I tried to be as thorough as possible.
Thank you for any guidance you can give.