http://otakushrine.elementfx.com/
its not working because of the other 2 javascripts i have, altough i made them external .js files, it still doesnt work... i started learning it today, hope you can see my problem here :happysad:
http://otakushrine.elementfx.com/
its not working because of the other 2 javascripts i have, altough i made them external .js files, it still doesnt work... i started learning it today, hope you can see my problem here :happysad:
Hmm, I can't access the web site...
perhaps if you post the code...
Move the javascript code below the <body> tag.
Like so:
HTML Code:<body onload="message();"> <script type="text/javascript"> function message() { alert("currently working on another website and learning javascript"); } </script> ....
Also acceptable:Code:<script type="text/javascript"> function message() { alert("currently working on another website and learning javascript"); } </script> <body onLoad="javascript:message();">
Code:<script type="text/javascript"> function message() { alert("currently working on another website and learning javascript"); } </script> <body onLoad="message();">
Last edited by daman371; 09-17-2008 at 08:09 PM.
Yep, try removing all other javascripts first, then when you add them, if they break it, you know where the problem is!
If the following code is on your page, without any other script, it will work:
Code:<head> ... <script type="text/javascript"> function message() { alert("Welcome"); } </script> </head> <body onLoad="message();"> ...
I mentioned above the script alert message works only if i take those 2 other .js scripts, somehow they cancel the alert message and the code inside .js files is this:
Date.js
time.js//<![CDATA[
/*Current date script credit:
JavaScript Kit (www.javascriptkit.com)
*/
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December")
document.write("<font color='#BBD6EC' face='Palatino Linotype'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font>")
//]]>
//<![CDATA[
/*By JavaScript Kit
http://javascriptkit.com
Credit MUST stay intact for use
*/
function show2(){
if (!document.all&&!document.getElementById)
return
thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="PM"
if (hours<12)
dn="AM"
if (hours>12)
hours=hours-12
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
var ctime=hours+":"+minutes+":"+seconds+" "+dn
thelement.innerHTML="<b style='color:#BBD6EC; font-family:times new roman'>"+ctime+"</b>"
setTimeout("show2()",1000)
}
window.onload=show2
//]]>
Last edited by Otaku Ichise; 09-18-2008 at 11:08 AM.
Use this for your time.js
I cleaned up your script. You should really use semicolons (;)...Code://<![CDATA[ /*By JavaScript Kit http://javascriptkit.com Credit MUST stay intact for use */ function show2(){ if (!document.all&&!document.getElementById){ return;} thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2; var Digital=new Date(); var hours=Digital.getHours(); var minutes=Digital.getMinutes(); var seconds=Digital.getSeconds(); var dn="PM"; if (hours<12){ dn="AM";} if (hours>12){ hours=hours-12;} if (hours==0){ hours=12;} if (minutes<=9){ minutes="0"+minutes;} if (seconds<=9){ seconds="0"+seconds;} var ctime=hours+":"+minutes+":"+seconds+" "+dn; thelement.innerHTML="<b style='color:#BBD6EC; font-family:times new roman'>"+ctime+"</b>"; setTimeout(show2(),1000); } window.onload=show2(); //]]>
Yep those scripts were the problem.
I'd suggest replacing the Date script with the following (much shorter) php:
look up the date() function for additional informationPHP Code:<?php
$dat=date("D jS F Y");
echo "<font color='#BBD6EC' face='Palatino Linotype'><b>$dat</b></font>";
?>
Last edited by mattura; 09-19-2008 at 03:12 AM.