Click to See Complete Forum and Search --> : changing text
r00tsec
07-28-2003, 01:21 PM
Does anyone know where I can find a script to dynamically change the text based on the date or the the users IP, I want something where I can have the text change (such as things that are being offered on the site) everyday without me having to go into the code and change it everyday. Is something like this possible? Thanks!
Nevermore
07-28-2003, 01:35 PM
Yes. Here's an example - I don't know if it's any use to you.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var dmy = "Today's Date: "+day+"/"+month+"/"+year
// -->
</script>
</head>
<body onload="document.getElementById('dmy').firstChild.nodeValue=dmy">
<a id="dmy">If you have JavaScript, the date will be displayed here.</a>
</body>
</html>
r00tsec
07-28-2003, 10:16 PM
Yeah, I am still a little conufsed. Say you wanted a pice of text with the following strings to change everyday, or based off the users IP. "Hello World" "Hello World Two" "Hello World Three". How would I write the JS to switch this dynamically?
Charles
07-29-2003, 03:53 AM
<script type="text/javascript">
<!--
messages = ['Hello World One', 'Hello World Two', 'Hello World Three'];
document.write('<p>', messages[new Date().getDate() % messages.length], '</p>')
// -->
</script>
r00tsec
07-29-2003, 11:23 AM
thanks!
r00tsec
07-29-2003, 12:49 PM
ok, im sorry, im new to JS, but I was wondering how would you go about changing the font color in the above code?
Charles
07-29-2003, 01:16 PM
<script type="text/javascript">
<!--
messages = ['Hello World One', 'Hello World Two', 'Hello World Three'];
document.write('<p style="color:#900">', messages[new Date().getDate() % messages.length], '</p>')
// -->
</script>
r00tsec
07-29-2003, 01:19 PM
thanks so much!:)