/    Sign up×
Community /Pin to ProfileBookmark

Displaying different content according to user’s system clock

I am trying to display two or three different flash files according to the user’s system clock time. I have gotten the code to display different pictures, however it does not seem to work for Flash files. Basically, I have a flash movie of the outside of our building. I would like to display different ones for morning, afternoon and night. Thanks for any help guys!!

to post a comment
Full-stack Developer

6 Comments(s)

Copy linkTweet thisAlerts:
@PineSolPirateSep 24.2007 — Do you have some example code of what you are trying?

You might consider serving it up based on the servers time rather than the clients.
Copy linkTweet thisAlerts:
@jtap06authorSep 24.2007 — I am using this script:

[CODE]<body><script>
<!--
/*By George Chiang (JK's JavaScript tutorial)
http://www.javascriptkit.com
Credit must stay intact for use*/
var current= new Date()
var day_night=current.getHours()
if (day_night<=12)
document.write("<img src='index_files/opening.swf'>")
else
document.write("<img src='index_files/night.swf'>")
//-->
</script>[/CODE]


It works fine with static pictures(jpegs or gifs) but it will not open flash files.
Copy linkTweet thisAlerts:
@jtap06authorSep 24.2007 — <body><script>

<!--

/*By George Chiang (JK's JavaScript tutorial)

http://www.javascriptkit.com

Credit must stay intact for use*
/

var current= new Date()

var day_night=current.getHours()

if (day_night<=12)

document.write("<img src='index_files/opening.swf'>")

else

document.write("<img src='index_files/night.swf'>")

//-->

</script>
Copy linkTweet thisAlerts:
@PineSolPirateSep 24.2007 — Have you tried replacing img with embed?

[code=html]<embed src="Yourfilename.swf" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">[/code]
Copy linkTweet thisAlerts:
@jtap06authorSep 24.2007 — Nope, still not working... ?
Copy linkTweet thisAlerts:
@PineSolPirateSep 24.2007 — Hmm, I can't really test this myself, I don't have an swf files at work. When I get home I'll play around with it. In the meantime, try adding both items to the page, then only showing one of them. Not too old browser compat, but thats life right?
[code=php]<html>

<body style="background: #000;">

<embed id="swf2" style="display: none;" src="index_files/opening.swf" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
<embed id="swf1" style="display: none;" src="index_files/night.swf" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

</body>
<script>
var current= new Date()
var day_night=current.getHours()
if (day_night<=12)
document.getElementById('swf1').style.display = '';
else
document.getElementById('swf2').style.display = '';
</script>
</html>[/code]
×

Success!

Help @jtap06 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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