2
   

Changing a font style, color and size inside a javascript

 
 
Reply Mon 29 Mar, 2004 01:53 pm
Hi all,
I'm "kingskid" and a real novice when it comes to web site development. This is my first post, so be nice. Smile

My question pertains to being able to insert additional code lines (if possible) into an existing script to be able to change the font type, color and size.

There is nothing in the script that identifies what the font is or anything else for that matter. Being new at this stuff, I'm sure there's an easy fix…or maybe not.

I found the script file at: http://javascript.internet.com and its called "Current Date & Time (long)".

I'm not sure whom to ask, so I'm turning to you guys. Any help or direction would be greatly appreciated.

Thanks in advance.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 2,331 • Replies: 4
No top replies

 
Craven de Kere
 
  1  
Reply Mon 29 Mar, 2004 01:57 pm
Sounds like this script: http://search.able2know.com/Web_Development/Scripts/JavaScript/Time___Date/Current_Date_&_Time_(long)_L4152/

I'll post some code in a sec.
0 Replies
 
Craven de Kere
 
  1  
Reply Mon 29 Mar, 2004 02:00 pm
Code:<!-- Copy this code into the BODY of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
// Script featured on Able2Know.com
// Find free scripts & get free help: http://search.able2know.com/web_development/scripts/

<!-- Begin
var day="";
var month="";
var myweekday="";
var year="";
newdate = new Date();
mydate = new Date();
dston = new Date('April 4, 1999 2:59:59');
dstoff = new Date('october 31, 1999 2:59:59');
var myzone = newdate.getTimezoneOffset();
newtime=newdate.getTime();

var zone = 6; // references your time zone

if (newdate > dston && newdate < dstoff ) {
zonea = zone - 1 ;
dst = " Pacific Daylight Savings Time";
}
else {
zonea = zone ; dst = " Pacific Standard Time";
}
var newzone = (zonea*60*60*1000);
newtimea = newtime+(myzone*60*1000)-newzone;
mydate.setTime(newtimea);
myday = mydate.getDay();
mymonth = mydate.getMonth();
myweekday= mydate.getDate();
myyear= mydate.getYear();
year = myyear;

if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
myhours = mydate.getHours();
if (myhours >= 12) {
myhours = (myhours == 12) ? 12 : myhours - 12; mm = " PM";
}
else {
myhours = (myhours == 0) ? 12 : myhours; mm = " AM";
}
myminutes = mydate.getMinutes();
if (myminutes < 10){
mytime = ":0" + myminutes;
}
else {
mytime = ":" + myminutes;
};
arday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
armonth = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ", "October ","November ","December ")
ardate = new Array("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st");
// rename locale as needed.

var time = ("<font color=\"#FF0000\">In Dallas, Texas, it is: " + myhours + mytime+ mm + ", " + arday[myday] +", " + armonth[mymonth] +" "+ardate[myweekday] + ", " + year+", " + dst +".</font>");
document.write(time);
//-->
</SCRIPT>


Made it red there.

Note the line:

Code:var time = ("<font color=\"#FF0000\">In Dallas, Texas, it is: " + myhours + mytime+ mm + ", " + arday[myday] +", " + armonth[mymonth] +" "+ardate[myweekday] + ", " + year+", " + dst +".</font>");


Put whatever formatting you want there. Make sure to escape any quotation marks like I did in my example.
0 Replies
 
kingskid
 
  1  
Reply Mon 29 Mar, 2004 02:30 pm
Much Thanks!
Thank you Craven de Kere! Laughing

I tried the fix and it works like a charm!

Thank you very much.
0 Replies
 
Craven de Kere
 
  1  
Reply Mon 29 Mar, 2004 02:47 pm
No problem. Welcome to A2K!
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Changing a font style, color and size inside a javascript
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/24/2024 at 04:42:52