/    Sign up×
Community /Pin to ProfileBookmark

Message/pic to be displayed at certain times on certain days

Salutations! I’m a radio presenter, and I’ve designed 2 different little piccies saying ‘ON AIR’ (one for each station) and another saying ‘OFF AIR’ for my site, but I want a code that will enable the pics to CHANGE when I’m obviously on or off air.

These are the times etc.

Station 1: ON AIR Wednesday 5-7pm
Station 2: ON AIR Saturday 6-7pm
ON AIR Sunday 6-9pm

These are subject to change, but you get the idea. At all OTHER times, I want the ‘OFF AIR’ to be shown, but when I’m broadcasting, obviously I need the RIGHT piccy (and hyperlink?).

Any help greatly appreciated. All you Java Programmers I salute you!

DJ Jen

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JMay 04.2004 — Please try the following


<HTML>

<HEAD>

<TITLE>Document Title</TITLE>

<script>

<!--

today=new Date()

day=today.getDay()

hour=today.getHours()

minute=today.getMinutes()

on=0

function chk_status(){

document.working.src="off_air.gif"

if(day==2&&hour>=17&&hour<19){

document.working.src="on_air.gif"

on=1

}

if(day==6&&hour>=18&&hour<19){

document.working.src="on_air.gif"

on=1

}

if(day==0&&hour>=18&&hour<21){

document.working.src="on_air.gif"

on=1

}

}

function go_url(){

if(on==0){

location="off_air.htm"

}

else{

location="on_air.htm"

}

}

// add onload="chk_status()" to the opening BODY tag

// -->

</script>



</HEAD>

<BODY onload="chk_status()">

<img name="working" src="off_air.gif" onclick="go_url()">


</BODY>

</HTML>
Copy linkTweet thisAlerts:
@djjenyauthorMay 05.2004 — How do i display some text/hyperlink with that?

i.e. underneath picture: "Click [url=http://www.listen.com]here[/url] to listen live!"

Jen x
Copy linkTweet thisAlerts:
@Mr_JMay 05.2004 — I wasn't sure how you wanted the link to funciton so I made the image as a link.

I have amended the script so that a link with the wording " "Click here to listen live!" is shown under the image when the "On Air" image is shown.

At all other times the link will be hidden.

Let me know if this is ok


[SIZE=1]

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>

<script>

<!--



function chk_status(){

today=new Date()

day=today.getDay()

hour=today.getHours()



document.working.src="off_air.gif"

document.getElementById("golive").style.visibility="hidden"

if(day==2&&hour>=17&&hour<19){ // tuesday 5pm - 7pm

document.working.src="on_air.gif"

document.getElementById("golive").style.visibility="visible"

}



if(day==6&&hour>=18&&hour<19){ // saturday 6pm - 7pm

document.working.src="on_air.gif"

document.getElementById("golive").style.visibility="visible"

}



if(day==0&&hour>=18&&hour<21){ // sunday 6pm - 9pm

document.working.src="on_air.gif"

document.getElementById("golive").style.visibility="visible"

}



setTimeout("chk_status()",1000)



}



// add onload="chk_status()" to the opening BODY tag

// -->

</script>



</HEAD>

<BODY onload="chk_status()">



<div>

<img name="working" src="off_air.gif">

<div id="golive">Click <a href="yourpage.htm">here</a> to listen live!"</div>

</div>



</BODY>

</HTML>



[/SIZE]
Copy linkTweet thisAlerts:
@djjenyauthorMay 06.2004 — That's fantastic ? But could you also get it to CHANGE the text depending on the day?? (I.e. I want the Wednesday text/link to be different to Sat/Sun since I work for 2 different stations).

Many many thanks, u're a star ?
Copy linkTweet thisAlerts:
@Mr_JMay 06.2004 — Here you go, just be carefully about the [COLOR=red]delimiter[/COLOR] and [COLOR=red]quotes[/COLOR] when entering your own text

[SIZE=1]

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>

<script>

<!--

[B]

tue_message="Click <a href=[COLOR=red]"[/COLOR]yourpage.htm[COLOR=red]"[/COLOR]>here</a> to listen live!"

sat_message="Click <a href=[COLOR=red]"[/COLOR]yourpage.htm[COLOR=red]"[/COLOR]>here</a> to listen live!"

sun_message="Click <a href=[COLOR=red]"[/COLOR]yourpage.htm[COLOR=red]"[/COLOR]>here</a> to listen live!"

[/B]


function chk_status(){

today=new Date()

day=today.getDay()

hour=today.getHours()



document.working.src="off_air.gif"

document.getElementById("golive").style.visibility="hidden"

if(day==2&&hour>=17&&hour<19){ // tuesday 5pm - 7pm

document.working.src="on_air.gif"

document.getElementById("golive").innerHTML=tue_message

document.getElementById("golive").style.visibility="visible"

}



if(day==6&&hour>=18&&hour<19){ // saturday 6pm - 7pm

document.working.src="on_air.gif"

document.getElementById("golive").innerHTML=sat_message

document.getElementById("golive").style.visibility="visible"

}



if(day==0&&hour>=18&&hour<21){ // sunday 6pm - 9pm

document.working.src="on_air.gif"

document.getElementById("golive").innerHTML=sun_message

document.getElementById("golive").style.visibility="visible"

}



setTimeout("chk_status()",1000)



}



// add onload="chk_status()" to the opening BODY tag

// -->

</script>



</HEAD>

<BODY onload="chk_status()">



<div>

<img name="working" src="off_air.gif">

<div id="golive"></div>

</div>



</BODY>

</HTML>

[/SIZE]
×

Success!

Help @djjeny 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.20,
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,
)...