/    Sign up×
Community /Pin to ProfileBookmark

show image depending on date range

Hello, I diplay an image on my page, and user jquery script to show another image when mouse rollovers.

However I would like to show one image only during certain date range that can be configured like 2014-05-01 to 2014-07-01 etc.

Else another “expired” image needs to be shown.

My current code is like this:

[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>URL Screenshot Preview with jQuery</title>
<meta name=”description” content=”Easiest jQuery Tooltip Ever”>
<script src=”http://www.gamafix.lt/badge/jquery.js” type=”text/javascript”></script>
<script src=”http://www.gamafix.lt/badge/main.js” type=”text/javascript”></script>
</meta>

<style>
body {
margin:0;
padding:40px;
background:#fff;
font:80% Arial, Helvetica, sans-serif;
color:#555;
line-height:180%;
}

h1{
font-size:180%;
font-weight:normal;
color:#555;
}
h2{
clear:both;
font-size:160%;
font-weight:normal;
color:#555;
margin:0;
padding:.5em 0;
}
a{
text-decoration:none;
color:#f30;
}
p{
clear:both;
margin:0;
padding:.5em 0;
}
pre{
display:block;
font:100% “Courier New”, Courier, monospace;
padding:10px;
border:1px solid #bae2f0;
background:#e3f4f9;
margin:.5em 0;
overflow:auto;
width:800px;
}

img{border:none;}
ul,li{
margin:0;
padding:0;
}
li{
list-style:none;
float:left;
display:inline;
margin-right:10px;
}

/* */

#screenshot{
position:absolute;
border:1px solid #ccc;
background:#333;
padding:5px;
display:none;
color:#fff;
}

/* */
</style>
</head>
<body>

<a href=”http://www.gamafix.lt” title=”www.gamafix.lt – Spalvu Valdymo Sprendimai” class=”screenshot” rel=”http://www.gamafix.lt/badge/2014-klp-1.png” target=”_blank”><img src=”http://www.gamafix.lt/badge/ISO12647-2.png” alt=”Spaudos sertifikacija” width=”150″ height=”116″ border=”0″></a>

</body>
</html>[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@smilemauthorMay 30.2014 — This date interval code works OK, but I would like to add year check and how do I make it a single script?

&lt;html&gt;
&lt;head&gt;

&lt;script language="javascript"&gt;
&lt;!--
var picture='';
mytime=new Date();
mymonth=mytime.getMonth()+1;
mydate=mytime.getDate();
if (mymonth==5 &amp;&amp; mydate&lt;=30) {picture="&lt;img src=image to show.png&gt;"}
else if (mymonth==6 &amp;&amp; mydate&lt;=30) {picture="&lt;img src=image to show.png&gt;"}
else {picture="&lt;img src=image to show else case.png&gt;"
}
//--&gt;
&lt;/script&gt;


&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;script language="javascript"&gt;
if(picture!='')
{
document.write(picture);
}

&lt;/script&gt;

&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
×

Success!

Help @smilem spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...