External Javascript files....

liunx

Guest
I have a site I made using DW. I want to take all the JS out of the code and move it to external files. <br />
I made a folder called scripts to hold all the .js files.<br />
I put the call :<scripttype="text/javascript"language="javascript"src=http://www.htmlforums.com/archive/index.php/"scripts/nameoffile.js"></script> in between the the div tags in the code.<br />
After doing that and testing, I'm not getting an image to show up in the layer.<br />
THe js file nameoffile.js does not have any tags wrapped around the code.<br />
Is there a problem?<!--content-->in the "<head>" section:<br />
<br />
<br />
<script type="text/javascript" language="javascript" src=http://www.htmlforums.com/archive/index.php/"scripts/nameoffile.js"></script><!--content-->don't assume I know what I'm doing, see now I don't know what you're talking about and I'm left hanging<!--content-->ok, now I'm confussed :eek:<br />
<br />
how much of html do you know?<!--content-->still learning, but to answer you're question, I know 22.6 percent of it.EOM<!--content-->Try this instead:<br />
<br />
<br />
<script type="text/javascript" src=http://www.htmlforums.com/archive/index.php/"scripts/nameoffile.js"></script><!--content--><scripttype="text/javascript"language="javascript"src=http://www.htmlforums.com/archive/index.php/"scripts/nameoffile.js"></script> <br />
<br />
All I can see is that the contents of the tag areallruntogether. You'll need this instead:<br />
<br />
<script type="text/javascript" language="javascript" src=http://www.htmlforums.com/archive/index.php/"scripts/nameoffile.js"></script><!--content-->look don't be :mad: <br />
<br />
We all learn each day something new.<br />
And at this forum, I sure that they are experts<br />
and rockies....<br />
<br />
Since You are using Dreamweaver,<br />
view the source of your page.<br />
Than search for tha tag the above I mention<br />
between the tags that I mention; delete the<br />
old one.<br />
<br />
Make a backup file...<br />
<br />
ok? <br />
:)<!--content-->to do in this topic and still no go. Here's the script in the .js file (as you see it):<br />
<br />
// Kaosweaver Live Clock Start<br />
function class_clock(f,s,c,b,w,h,d,m) { // Copyright 2002 by Kaosweaver, All rights reserved<br />
this.b=b;this.w=w;this.h=h;this.d=d;<br />
this.o='<font style="color:'+c+'; font-family:'+f+'; font-size:'+s+'pt;">';<br />
if (m==1) this.o+=doDate("W0","%20%20%20%20","M1","%20%20","D1",",%20%20","Y0","%20%20%20%20%20");<br />
<br />
}<br />
var clock=new class_clock("Arial, Helvetica, sans-serif","10","#00FF99","#000000","287",1,1,1)<br />
// If the clock's size needs adjusting, change the 287 above.<br />
d=document<br />
if (d.all || d.getElementById) {d.write('<span id="activeClock" style="width:'+clock.w+'px; background-color:'+clock.b+'"></span>'); }<br />
else if (d.layers) {d.write('<ilayer bgcolor="'+clock.b+'" id="wrapClock"><layer width="'+clock.w+'" id="activeClock"></layer></ilayer>'); }<br />
else {KW_doClock(1);}<br />
function KW_doClock(a) { // Copyright 2002 by Kaosweaver, All rights reserved<br />
d=document;t=new Date();p="";dClock="";if (d.layers) d.wrapClock.visibility="show";<br />
h=t.getHours();m=t.getMinutes();s=t.getSeconds();if (clock.h)<br />
{p=(h>11)?"PM":"AM";h=(h>12)?h-12:h;h=(h==0)?12:h;}if (clock.d)<br />
{m=(m<=9)?"0"+m:m; s=(s<=9)?"0"+s:s;} dClock = clock.o+h+':'+m+':'+s+' '+p+'</font>';<br />
if (a) {d.write(dClock);}if (d.layers) {wc = document.wrapClock;lc = wc.document.activeClock;<br />
lc.document.write(dClock);lc.document.close();<br />
} else if (d.all) {activeClock.innerHTML = dClock;<br />
} else if (d.getElementById) {d.getElementById("activeClock").innerHTML = dClock;}<br />
if (!a) setTimeout("KW_doClock()",1000);<br />
}<br />
<br />
<br />
function doDate(){ // Copyright 2002 by Kaosweaver, All rights reserved.<br />
var t=new Date(),a=doDate.arguments,str="",i,a1,lang="1";<br />
var month=new Array('January','Jan', 'February','Feb', 'March','Mar', 'April','Apr', 'May','May', 'June','Jun', 'July','Jul', 'August','Aug', 'September','Sep', 'October','Oct', 'November','Nov', 'December','Dec');<br />
var tday= new Array('Sunday','Sun','Monday','Mon', 'Tuesday','Tue', 'Wednesday','Wed','Thursday','Thr','Friday','Fri','Saturday','Sat');<br />
for(i=0;i<a.length;i++) {a1=a.charAt(1);switch (a.charAt(0)) {<br />
case "M":if ((Number(a1)==3) && ((t.getMonth()+1)<10)) str+="0";<br />
str+=(Number(a1)>1)?t.getMonth()+1:month[t.getMonth()*2+Number(a1)];break;<br />
case "D": if ((Number(a1)==1) && (t.getDate()<10)) str+="0";str+=t.getDate();break;<br />
case "Y": str+=(a1=='0')?t.getFullYear():t.getFullYear().toString().substring(2);break;<br />
case "W":str+=tday[t.getDay()*2+Number(a1)];break; default: str+=unescape(a);}}return str;<br />
}<br />
<br />
// Kaosweaver Live Clock End<br />
<br />
<br />
<MM:BeginLock translatorClass="KW_LC" type="script" depFiles="" orig="%3C!--%20KW%20Live%20Clock%20--%3E">8:35:32 2/18/103<MM:EndLock><!--content-->Make a new text file called test.js and just put this in it:<br />
<br />
document.write("test from external file");<br />
<br />
<br />
Alter your link to point to this file for a moment, upload it all and try it out. This will verify if it is the calling of the external file that fails, or else something within the file that fails to run.<!--content-->I already know the code is fine, it worked fine before I moved it to an external file. I'm just doing something wrong in the linking.<br />
Recap on what changed:<br />
<br />
I moved that call (mentioned above) to in between the same two div> tags the ENTIRE clock code was once in and moved the ENTIRE clock code to the external .js file.<br />
<br />
Note that the new .js file has NO tags ( which I think is right).<br />
<br />
check out the remote site :www.bassanglersofsandiego.pair.com<br />
<br />
BTW, how does this ranking thing go? I just noticed I'm level 2, what's that mean?<!--content-->As it will take only 5 minutes to try it, just try the other file for a moment. It will either show that you made a silly error somewhere, or it will confirm that you were right.<br />
<br />
<br />
Level 2? You go up a level after certain numbers of posts. Use the forum search, and you'll find a lot of information about that, as well as details of the names and number of posts for each level.<!--content-->ok, the test.js file didn't work either, which tells it has to be linking, I tried <script type="text/javascript" language="javascript" src=http://www.htmlforums.com/archive/index.php/"scripts/test.js"></script> and <script type="text/javascript" language="javascript" src="../scripts/test.js"></script> what else is there?<!--content-->Erase everything out of your mind and focus! ;) <br />
<br />
Open Notepad, type document.write("Testing");<br />
and save it as testing.js in the scripts directory.<br />
<br />
(BTW where is your scripts directory in relation to your html file? I am assuming your scripts directory is in the directory where your html files are. The . means current directory and .. means go one dir down)<br />
<br />
In your page, add the following, NOT IN THE HEAD, but in the place that you would like the date to appear (in the BODY):<br />
<br />
<script type="text/javascript" src=http://www.htmlforums.com/archive/index.php/"scripts/testing.js"></script><br />
<br />
It should work. I use the same concept in my webpage.<!--content-->Read my post called "what's the point?". I'm about to give up on this, seems pointless anyways. Isn't external linking just internal redirection creating an unneccessary path (which in turn takes more time)?<!--content-->
 
Back
Top