/    Sign up×
Community /Pin to ProfileBookmark

schedule image wont work…

I added a script to this page and it won’t display the picture thats based on a schedule on [URL=http://www3.mb.sympatico.ca/~jgiesbrt/freq107/index.htm ]http://www3.mb.sympatico.ca/~jgiesbrt/freq107/index.htm [/URL] Does anyone have any suggestions, Here’s the script i added:
<img src=”onairpicsimageson_air_overnight.gif” onload=”setImage(this)”>

<script type=”text/javascript”>
function setImage(img){
var now = new Date();
var day = now.getDay();
var hours = now.getHours();

if (day == 0){ // Sunday pics
if (hours < 9){
img.src = ‘onairpicsimageson_air_overnight.gif’;
} else if (hours < 15){
img.src = ‘onairpicsimageson_air_crash.gif’;
} else if (hours < 21){
img.src = ‘onairpicsimageson_air_doug.gif’;
} else {
img.src = ‘onairpicsimageson_air_overnight.gif’;
}
} else if (day == 6){ // Saturday pics
if (hours < 9){
img.src = ‘onairpicsimageson_air_overnight.gif’;
} else if (hours < 15){
img.src = ‘onairpicsimageson_air_doug.gif’;
} else if (hours < 21){
img.src = ‘onairpicsimageson_air_crash.gif’;
} else {
img.src = ‘onairpicsimageson_air_overnight.gif’;
}
} else { // Mon – Fri pics
if (hours < 6){
img.src = ‘onairpicsimageson_air_overnight.gif’;
} else if (hours < 10){
img.src = ‘onairpicsimageson_air_brian.gif’;
} else if (hours < 15){
img.src = ‘onairpicsimageson_air_gen.gif’;
} else if (hours < 19){
img.src = ‘onairpicsimageson_air_buzz.gif’;
} else {
img.src = ‘onairpicsimageson_air_steve.gif’;
}
}
}
</script>

Hope you can help
I’m stumped!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonOct 11.2003 — I think that this should go into the body tag:

onload="setImage(this)"

and of course you won't be able to put "this" in the brackets. I would suggest doing this:

<script type="text/javascript"><!--

function setImage(){

img=document.getElementById("an_img");

...

//--></script>

</head>

<body onload="setImage();">

<img src="onairpicsimageson_air_overnight.gif" alt="on air overnight">

By the way, the page you gave an address to was a 404 page not found.
Copy linkTweet thisAlerts:
@crashauthorOct 11.2003 — hey sorry bout that, i was just updating. I'll try those scripts and see if they work.

thx

here's the site


[URL=http://www3.mb.sympatico.ca/~jgiesbrt/Freq107/]web page[/URL]
Copy linkTweet thisAlerts:
@crashauthorOct 11.2003 — I tride those codes everywhere and they're not working. if you could check out the site and view source and see what i should change that would be awesome.

thanks again,
Copy linkTweet thisAlerts:
@Aronya1Oct 13.2003 — Your path is wrong. The image is in the 'onairpics' folder, not in onairpics/images.

Get the path right & remove the 'onload="setImage(this)"' part, & it comes up fine.
×

Success!

Help @crash 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 6.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...