How do I position this script?

liunx

Guest
Hi All,<br />
I have got this script for the date on my site<br />
<script language="JavaScript"><br />
// -- made by A1javascripts.com, please keep these credits when using this script<br />
days = new Array(7)<br />
days[1] = "Sun";<br />
days[2] = "Mon";<br />
days[3] = "Tue"; <br />
days[4] = "Wed";<br />
days[5] = "Thu";<br />
days[6] = "Fri";<br />
days[7] = "Sat";<br />
months = new Array(12)<br />
months[1] = "Jan";<br />
months[2] = "Feb";<br />
months[3] = "Mar";<br />
months[4] = "Apr";<br />
months[5] = "May";<br />
months[6] = "Jun";<br />
months[7] = "Jul";<br />
months[8] = "Aug";<br />
months[9] = "Sep";<br />
months[10] = "Oct"; <br />
months[11] = "Nov";<br />
months[12] = "Dec";<br />
today = new Date(); day = days[today.getDay() + 1]<br />
month = months[today.getMonth() + 1]<br />
date = today.getDate()<br />
year=today.getYear(); <br />
if (year < 2000)<br />
year = year + 1900;<br />
document.write ("<font size=-6 face='Helvetica, Arial, sans-serif' color=green> "+ day +<br />
", " + month + " " + date + ", " + year + "</font>" )<br />
// -- end hiding <br />
</script><br />
<br />
and I want to be able to position it down my left margin, but at the moment it stays top, left under my logo, no matter where I put it.<br />
<br />
<!-- m --><a class="postlink" href="http://www.marchingcrazy.com">http://www.marchingcrazy.com</a><!-- m --><!--content-->Try placing it just above these lines in your source code:<br />
<br />
<font size="2" face="helvetica"><B><a href=http://www.htmlforums.com/archive/index.php/"http://www.marchingcrazy.com/lost.htm" onMouseOver="checkbrowser()" target="_blank" STYLE="text-decoration: none">DO NOT TOUCH!</a></B></td></tr><br />
</table><!--content-->The script has to be IN the page.<br />
Add it in this part:<br />
---------------<br />
DO NOT <br />
TOUCH!</A></B></FONT><br />
<p><br />
<SCRIPT language=JavaScript><br />
<br />
// -- made by A1javascripts.com, please keep these credits when using this script<br />
days = new Array(7)<br />
days[1] = "Sun";<br />
days[2] = "Mon";<br />
-----------------<!--content-->Couldn't the document.write part be put into a variable and the variable plugged into the HTML code anywhere its wanted?<br />
<br />
Kevin<!--content-->Yup. Two completely separate things are going on here -<br />
1) an (HTML) string with the date - formatted - is being generated; and<br />
2) the string is being output into the document.<br />
<br />
As surmised, there's no need to do them together. The only part of the script that has to be 'in the page' is the 'write()' part (there are ways around this too, but never mind). Just do:<br />
<br />
if (year < 2000) <br />
year = year + 1900; <br />
var dateStr = '<font size=-6 face="Helvetica,Arial,sans-serif" color="green">';<br />
dateStr += day + ', ' + month + ' ' + date + ', ' + year;<br />
dateStr += '</font>';<br />
<br />
</script><br />
<br />
Wherever you want the date to appear in the page, put:<br />
<br />
<script language="JavaScript" type="text/javascript"><br />
document.write(dateStr);<br />
</script><br />
<br />
You can surround the scriptlet with other HTML tags for further formatting.<!--content-->
 
Back
Top