/    Sign up×
Community /Pin to ProfileBookmark

Javascript doesn’t run Windows XPSP2

I copied the attached code from internet.com with the insertions to write “line 1” and “line 2”. Only “line 1” writes.
The HTML code after the script works OK.

What is wrong? Could there be a problem with the way Javascript is installed on my PC?

?

[upl-file uuid=e1aa9cff-d541-4309-8d86-39ec16772190 size=916B]clock.txt[/upl-file]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PittimannJan 20.2005 — [i]Originally posted by Trevor Lawrence [/i]

[B]What is wrong? Could there be a problem with the way Javascript is installed on my PC?[/B][/QUOTE]
No, js is fully available on your PC.

It is the code, you are using. jAVasCripT is case sensitive and you are using lower case characters where upper case is required. Something like this:

<script type="text/javascript">

document.write("line 1<br>")

var months=new Array(13);

document.write("line 2")

months[1]="january";

months[2]="february";

months[3]="march";

months[4]="april";

months[5]="may";

months[6]="june";

months[7]="july";

months[8]="august";

months[9]="september";

months[10]="october";

months[11]="november";

months[12]="december";

var time=new Date();

var lmonth=months[time.getMonth() + 1];

var date=time.getDate();

var year=time.getFullYear();

document.write("<center>" + lmonth + " ");

document.write(date + ", " + year + "</center>");

// end -->

</script>

should work for you.

Chers - Pit
Copy linkTweet thisAlerts:
@Trevor_LawrenceauthorJan 20.2005 — Thank you so much

I was used to HTML which apparently recommends lower case, although I understand both work (at present)

Are all versions of Javascript (if therr ar more than one) case sensitive?

?
Copy linkTweet thisAlerts:
@PittimannJan 20.2005 — Hi!Are all versions of Javascript (if therr ar more than one) case sensitive?[/QUOTE]Yes! And due to that, you should not modify the character case in scripts you download from somewhere. The mistake, which stopped the execution of your code already happened here:

var months=new [B][COLOR=red]a[/COLOR][/B]rray(13);

The [B][COLOR=red]a[/COLOR][/B] must be upper case. The variable name 'months' could be 'moNTh' without a problem, but you would have to use exactly the same, when referring to it in your script.

Cheers - Pit
×

Success!

Help @Trevor_Lawrence spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...