Egghead Posted February 2, 2007 Share Posted February 2, 2007 Hey all, well I have a really basic webpage on my computer right now that I am working on, adding various things to learn and practice and experiment. Anyhow, I tried adding in some Javascript code and, well, some works and some doesn't. For example, when I add in the first example, the "Hello World!" code, that works fine right now, and the CSS allows the text of it to show (because the page has a colored background).But then when I try to add the code that shows a clock, nothing happens. I added the code in the proper areas, and tried different things, but still, nothing. What am I doing wrong that won't let this more advanced code work? My page has a black background, but I tried changing it to white again just to see if the clock was in fact working, but was being hid, but this wasn't the case either.Any advice is appreciated, thanks,---Egghead--- Link to comment Share on other sites More sharing options...
Egghead Posted February 3, 2007 Author Share Posted February 3, 2007 Bump Link to comment Share on other sites More sharing options...
smiles Posted February 3, 2007 Share Posted February 3, 2007 let me see your clock code Link to comment Share on other sites More sharing options...
Anders Moen Posted February 3, 2007 Share Posted February 3, 2007 I have a really basic clock code here. <HTML> <HEAD> <TITLE>Title</TITLE> <script TYPE="TEXT/JAVASCRIPT"> function startTime() { var today=new Date() var h=today.getHours() var m=today.getMinutes() var s=today.getSeconds() // add a zero in front of numbers<10 m=checkTime(m) s=checkTime(s) document.getElementById('txt').innerHTML=h+":"+m+":"+s t=setTimeout('startTime()',500) } function checkTime(i) { if (i<10) {i="0" + i} return i } </SCRIPT> </HEAD> <BODY ONLOAD="startTime()"> <div id="txt"> Here the clock comes</div> </BODY> </HTML> Link to comment Share on other sites More sharing options...
smiles Posted February 3, 2007 Share Posted February 3, 2007 I bet that he use the circle clock with full of minute hand, second hand, hour hand, they are images and he forgot to have exactly links of these images Link to comment Share on other sites More sharing options...
Egghead Posted February 9, 2007 Author Share Posted February 9, 2007 The clock code from the example above won't work for me either. Here is what I do: I copy-pasted it into Wordpad, saved it as "TestClock.html" and then tried to open it in AOL. It just takes me to a page filled with a paragraph of garbage though. Anyone know what I'm doing wrong?Thanks,---Egghead--- Link to comment Share on other sites More sharing options...
smiles Posted February 9, 2007 Share Posted February 9, 2007 AOL is graphic browser. certainly you can't see that code workswhy isn't IE, Firefox, Maxthon, Opera Link to comment Share on other sites More sharing options...
roondog Posted February 9, 2007 Share Posted February 9, 2007 The clock works fine in IE6, thats all i can check it in at the moment. Link to comment Share on other sites More sharing options...
Anders Moen Posted February 9, 2007 Share Posted February 9, 2007 Did you notice that I had written < in the first < in script type="" then? That might have ######ed it up :)Well, anyway, I've corrected it up now. Link to comment Share on other sites More sharing options...
Egghead Posted February 19, 2007 Author Share Posted February 19, 2007 Argh, I still can't get it work. I have it saved in a .html file, am I doing everything right? I try to open it in Internet Explorer 7, which then blocks the content and shows me a page of garbage, then asks if I want to allow the blocked content, I say yes, refresh the page, but it's still garbage :)I am positive it is just something incredibly STOOOPID and I am just too inexperienced programming-wise to figure it out right now Link to comment Share on other sites More sharing options...
Anders Moen Posted February 19, 2007 Share Posted February 19, 2007 Hmm...well, I inserted it to my site, just to check it, and it works fine with me...Here's the link (at the bottom)Code again: <html><head><title>Clock</title><script type="text/javascript"> function startTime() { var today=new Date() var h=today.getHours() var m=today.getMinutes() var s=today.getSeconds() // add a zero in front of numbers<10 m=checkTime(m) s=checkTime(s) document.getElementById('txt').innerHTML=h+":"+m+":"+s t=setTimeout('startTime()',500) } function checkTime(i) { if (i<10) {i="0" + i} return i } </script></head><body onload="startTime()"><div id="txt">Do not change the name of this div! Or the names in the JS script, UNLESS you know what you're doing;)</div></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now