Click to See Complete Forum and Search --> : help again with javascript


Momyst
07-08-2003, 11:29 AM
Hi to all,
Im using this script below but it puts the month before the date if you know what I mean. I would love to reverse this. This is an English site. Thanks in advance. Maureen
<!-- ONE STEP TO INSTALL BORN ON DATE:

1. Paste the coding into the BODY of your HTML document -->

<!-- STEP ONE: Copy this code into the BODY of your HTML document -->

<BODY>

<CENTER>
<!-- Original: http://www.jwp.bc.ca/saulm/html/bornon.htm -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<TABLE border=2 cellspacing=0 cellpadding=3>
<TR><TD bgcolor="#000044">
<FONT color="#4400ff" face=georgia,arial size=+1>
<CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write(document.title);
//-->
</SCRIPT>
</TD></TR>
<TR><TD bgcolor="#440000">
<FONT size=-1 color="#ff0000" face="trebuchet MS","arial">
<FONT color="#ff8800">Created on:</font>

<!-- Put the page creation date, here. -->

November 23, 2002

<BR>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie(name) {
var exp = new Date();
FixCookieDate (exp);
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
if (cval != null)
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var cookie_date=new Date(document.lastModified);
var expdate = new Date();
expdate.setTime(expdate.getTime()+(5*24*60*60*1000));
document.write("<Font color=ff8800>" + "Last updated: "+ "</font>" +document.lastModified);
document.write("");
if (!(cookie_date == GetCookie("cookie_date"))){
SetCookie("cookie_date",cookie_date,expdate);
document.write("<font color='yellow'><br>Site has had a mystic change since last visit...Enjoy!</font><br>");
}
// End -->
</SCRIPT>
</FONT>
</TD></TR>
</TABLE>
</CENTER>



<!-- Script Size: 2.64 KB -->

Charles
07-08-2003, 11:42 AM
<script type="text/javascript">
<!--
Date.prototype.toDateString = function () {return [this.getDate(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][this.getMonth()], this.getFullYear()].join(' ')}

alert (new Date().toDateString());
// -->
</script>

Momyst
07-08-2003, 12:17 PM
With reference to my earlier post, Charles kindly answered, but as I am a mere worman and dont know much about script, please dont be rude.......but could you tell me what to do with it..........ha ha .....thanks

hallim
07-08-2003, 12:27 PM
You can place it in your document like so:

<html>
<head><title>your page</title>

<script type="text/javascript">
<!--
Date.prototype.toDateString = function () {return [this.getDate(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][this.getMonth()], this.getFullYear()].join(' ')}

alert (new Date().toDateString());
// -->
</script>
</head>
<body>

put your content here

</body>
</html>

Momyst
07-08-2003, 12:31 PM
so do you mean I dont use the original script or add this in somewhere........told you, will have to give it to me in idiot proof thanks for helping. Maureen

Momyst
07-08-2003, 12:43 PM
Hi to all,
Im using this script below but it puts the month before the date if you know what I mean. I would love to reverse this. Th A couple of people tried to help me (see Previous posts today) but i just dont get it...could someone just alter it for me to work if thats possible. Thanks in advance. Maureen
<!-- ONE STEP TO INSTALL BORN ON DATE:

1. Paste the coding into the BODY of your HTML document -->

<!-- STEP ONE: Copy this code into the BODY of your HTML document -->

<BODY>

<CENTER>
<!-- Original: http://www.jwp.bc.ca/saulm/html/bornon.htm -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<TABLE border=2 cellspacing=0 cellpadding=3>
<TR><TD bgcolor="#000044">
<FONT color="#4400ff" face=georgia,arial size=+1>
<CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write(document.title);
//-->
</SCRIPT>
</TD></TR>
<TR><TD bgcolor="#440000">
<FONT size=-1 color="#ff0000" face="trebuchet MS","arial">
<FONT color="#ff8800">Created on:</font>

<!-- Put the page creation date, here. -->

November 23, 2002

<BR>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie(name) {
var exp = new Date();
FixCookieDate (exp);
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
if (cval != null)
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var cookie_date=new Date(document.lastModified);
var expdate = new Date();
expdate.setTime(expdate.getTime()+(5*24*60*60*1000));
document.write("<Font color=ff8800>" + "Last updated: "+ "</font>" +document.lastModified);
document.write("");
if (!(cookie_date == GetCookie("cookie_date"))){
SetCookie("cookie_date",cookie_date,expdate);
document.write("<font color='yellow'><br>Site has had a mystic change since last visit...Enjoy!</font><br>");
}
// End -->
</SCRIPT>
</FONT>
</TD></TR>
</TABLE>
</CENTER>



<!-- Script Size: 2.64 KB -->

Fang
07-08-2003, 01:37 PM
Replace:

document.write("<Font color=ff8800>" + "Last updated: "+ "</font>" +document.lastModified);

with:

var Days=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var Months=["January","February","March","April","May","June","July","August","September","October","November","December"];
var Updated=new Date(document.lastModified);
var Year=Updated.getYear();
if(Year<1900) {
Year +=1900;
}
var DateString=Days[Updated.getDay()]+" "+Updated.getDate()+" "+Months[Updated.getMonth()]+" "+Year+" "+Updated.getHours()+":"+Updated.getMinutes()+":"+Updated.getSeconds();
document.write("<Font color=ff8800>" + "Last updated: "+ "</font>" +DateString);

The other date you can change yourself.

Khalid Ali
07-08-2003, 01:40 PM
You do not need to create multiple threads for the same topic.Its not considered nice.

Momyst
07-08-2003, 02:44 PM
Ooops been told off........sorry didnt know how all this works.
Thanks Fang will give it a go.....not quite sure what you mean obout other date though.......I will have a fiddle.

Momyst
07-08-2003, 03:13 PM
Thanks Fang it did work (as you knew it would)