js files

They have: 16 posts

Joined: Jan 2006

I was told that putting my java script in an external js file would help the SE find my relevent text on my homepage easier, but my server doesn't support js, jsp files. Any suggestions? They said I could use another script. I don't really know what they meant. I'm still trying to learn.

They have: 17 posts

Joined: Jan 2006

A .js file is not the same as a .jsp file. I think maybe your host got confused. I'd be willing to bet that if you tried it, it would work. Try it out on a test page and see what happens.

Win a free copy of Windows Vista

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

It should work fine. Saying a server doesn't support JS files is like saying a server doesn't support HTML files. It's just never true.

The technical reason behind this is that JS and HTML are what is referred to as client-side applications. Your computer is just downloading text from the server, then trying to execute or interpret that text.

What you sometimes have to worry about is server-side applications. PHP, PERL and ASP are all examples of file types that are server-side applications. The server first executes these files, then sends the resulting text to your computer.

Wikipedia has a couple of articles on this:

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

Oh, and here's a tutorial on using external javascript files:

http://www.tizag.com/javascriptT/javascriptexternal.php

They have: 16 posts

Joined: Jan 2006

I tried referencing the js file I created on a test page and I received an Internet Explorer script error. How should I resolve this? It said it was an "Expected" error.

Busy's picture

He has: 6,151 posts

Joined: May 2001

did you put <script> tags inside the .js file? if so take them out.

The error should of told you the line number and postion on the line of the problem

They have: 16 posts

Joined: Jan 2006

Yes, I took out the <scripts> tags. My file begins with this: language="JavaScript" type="text/JavaScript">

Should that also be taken out? My error says it's line 2 character 24 which I think is the "type" part. Do you see anything wrong with this script? Thanks for your help

Busy's picture

He has: 6,151 posts

Joined: May 2001

yes take out language="JavaScript" type="text/JavaScript">
, should just be the javascript code in there

They have: 16 posts

Joined: Jan 2006

Thank you. I left this on the web page: <script src="scripts.js" language="JavaScript" type="text/JavaScript">

</script> and everything else in the js file and it seemed to work. Thanks for your help.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.