Hi all.

Before I say any more, I am a compete noob at JavaScript. I have been attempting to learn some though.

I want to make some Windows 7/Vista sidebar gadgets, so, as a practise, I am making a very simple calender. It uses a CSS to draw up a background image, which works fine. The manifest is fine, and it installs. I made a javascript to get the date, and I linked it into the base HTML source file. In the javascript, I have a section that uses "document.write()". When I start the gadget, however, I just see the background image and no text.

I opened the JavaScript with 'Microsoft Windows Based Script Host', which gives me an error saying that 'document' is undefined. I tried putting it directly into my HTML source file, but the same result occurs (no text, just the background image). From my understanding, 'document' means like the web-page or window (or something!) and doesn't need to be defined. Can someone point me in the right direction?

Here is the script (runs fine until "document.write()")

var months = new Array();
months[1] = "Jan"; months[2] = "Feb"; months[3] = "Mar";
months[4] = "Apr"; months[5] = "May"; months[6] = "Jun";
months[7] = "Jul"; months[8] = "Aug"; months[9] = "Sep";
months[10] = "Oct"; months[11] = "Nov"; months[12] = "Dec";

var thedate = new Date();
var day = thedate.getDay() + 1;
var month = thedate.getMonth() + 1;

Thanks :)

document is an object that exists (is defined) when you are running your javascript from a BROWSER window.

I opened the JavaScript with 'Microsoft Windows Based Script Host'

There you have it - you are NOT using a browser. instead of document.write try Wscript.Echo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.