/    Sign up×
Community /Pin to ProfileBookmark

javascript not working

hi,
i have this html code:

[CODE]<!DOCTYPE html>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html;charset=utf-8″>
<title>Date &amp; Time</title>
<script type=”type/javascript” src=”date-time.js”></script>
</head>
<body>
<h1>Date &amp; Time</h1>
<p>It is currently <span id=”output”>now</span>.</p>
</body>
</html>[/CODE]

and have this javascript linked to it.

[CODE]//tell the browser to run this script when the page has finished loading
window.onload = insertDateTime;

//insert the date & time
function insertDateTime()
{
//ensure a DOM-aware user agent
if (!document.getElementById) return;
if (!document.createTextNode) return;

//create a date-time object
var oNow = new Date();

//get the current date & time as a string
var sDateTime = oNow.toLocaleString();

//point to the target element where we want to insert the date & time
var oTarget = document.getElementById(‘output’);

//make sure the target is found
if (!oTarget) return;

//delete everything inside the target
while (oTarget.firstChild)
{
oTarget.removeChild(oTarget.firstChild);
}

//use the date-time string to create a new text node for the page
var oNewText = document.createTextNode(sDateTime);

//insert the new text to the span
oTarget.appendChild(oNewText)
}[/CODE]

for some reason i don’t get the response from the html that i’m supposed to get. like the date is not displaying. i wonder what’s wrong. any clue?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@cluefulMar 06.2011 — [CODE]<script type="[B][COLOR="Red"]type[/COLOR][/B]/javascript" src="date-time.js">
[/CODE]
[/QUOTE]
[CODE]<script type="[B]text[/B]/javascript" src="date-time.js">[/CODE]
Copy linkTweet thisAlerts:
@tomikoauthorMar 06.2011 — super!!!!!!!!!!! it's working now. thank you very much!
×

Success!

Help @tomiko 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...