Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-18-2004, 04:52 AM   #1
Member (9 bit)
 
Join Date: Jan 2004
Location: Singapore
Posts: 448
Embedding java into HTML

Got this java script from a website.
*oh no.. can't get this java script to be show.. cos of the tag script*

-
start with script language = "JavaScript"
end with /script
-

I wanna save them into a .js file and then call it from a HTML page. (Just using a css stylesheet)
I am using Macomedia Dreamweaver MX 2004.
What tag should i add into the HTML page?
And do i just paste all these source into a .js file and save it without adding any other tags?

Last edited by human1987; 09-18-2004 at 04:58 AM.
human1987 is offline   Reply With Quote
Old 09-18-2004, 09:16 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Put the JavaScript source in a text file, name it something like file.js.

In your HTML file, add the following to the head section:
PHP Code:
<script type="text/javascript" src="name.js/> 
To post code on these forums, use the [ code ] or [ php ] tags, without spaces.
aym is offline   Reply With Quote
Old 09-18-2004, 10:31 PM   #3
Member (9 bit)
 
Join Date: Jan 2004
Location: Singapore
Posts: 448
PHP Code:
<script language "JavaScript">
<!-- 
hide javascript
//Created by Chad Seymour for personal use on anyone's website, any change of this scripting will result
//in copyright infringements...


//get date and time
function clock() {
var 
now = new Date();
var 
hour now.getHours();
var 
mins now.getMinutes();
var 
secs now.getSeconds();
var 
year now.getYear();
var 
mon now.getMonth();
var 
day now.getDate();
var 
year = (year 1900);
var 
ampm;



//format hour
if (hour 11) {
var 
ampm "pm";
} else {
var 
ampm "am";
}


//format seconds
if (secs 10) {
var 
secs "0" secs;
}

//format minutes
if (mins 10) {
var 
mins "0" mins;
}

//convert from military time
if (hour 12) {
var 
hour = (hour 12);
}
if (
hour==0) {
var 
hour 12;
}

//convert to roman name
if (mon==1) {
var 
gmon "Janurary"; }
if (
mon==2) {
var 
gmon "Februrary"; }
if (
mon==3) {
var 
gmon "March"; }
if (
mon==4) {
var 
gmon "April"; }
if (
mon==5) {
var 
gmon "May"; }
if (
mon==6) {
var 
gmon "June"; }
if (
mon==7) {
var 
gmon "July"; }
if (
mon==8) {
var 
gmon "August"; }
if (
mon==9) {
var 
gmon "September"; }
if (
mon==10) {
var 
gmon "October"; }
if (
mon==11) {
var 
gmon "November"; }
if (
mon==12) {
var 
gmon "December"; }

//display date and time
window.statusgmon " " day +", " year "  " hour ":" mins +":" secs +" " ampm;


//do it again
setTimeout("clock();",500);
}


// done hiding -->
</script> 
Can't work...
omg.. cannot work now, even when just adding this lines into the head section!

Last edited by human1987; 09-18-2004 at 10:34 PM.
human1987 is offline   Reply With Quote
Old 09-19-2004, 07:37 AM   #4
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
You need to call that function somewhere in the page, for a clock I guess the best place is <body onload="clock();">.

A word of advice though, changing the statusbar text is annoying, it's one of the JavaScript features I disable in Firefox.
aym is offline   Reply With Quote
Old 09-20-2004, 06:47 AM   #5
Member (9 bit)
 
Join Date: Jan 2004
Location: Singapore
Posts: 448
But this is meant to be shown in the status bar?
//display date and time
window.status= gmon + " " + day +", " + year + " " + hour + ":" + mins +":" + secs +" " + ampm;
human1987 is offline   Reply With Quote
Old 09-20-2004, 09:38 AM   #6
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Yes, the clock appears in the status bar.
aym is offline   Reply With Quote
Old 09-20-2004, 11:29 AM   #7
Member (9 bit)
 
Join Date: Jan 2004
Location: Singapore
Posts: 448
However, i cannot embed it..
Might be changing it to other codes if it don't work...
human1987 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:53 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2