Click to See Complete Forum and Search --> : Left script on server as .js file - now script doesn't work. Please help!
Valery
12-12-2002, 04:39 PM
Hello All,
please excuse me for probably a very dumb question... I am no developer, just a M.D. and I am also new to JavaScript'ing...
I wanted to leave a script on the server to speed up the loading of pages where it is used and also to be able to make changes (if need be) only at one place (the script) instead of in all pages using it...
Now... According to the advice I found at CodeAvenue.com, I created a new folder on the server and put my script into it as a separate .js file, then I deleted the script from the page(s) using it and wrote there this instead:
<script language="JavaScript" src="_scripts/script_DE.js"></script>
Now the script doesn't work... I tried to put this line between <head> and </head> and then between <body> and </body> - all in vain... The script just won't work.
What did I do wrong? Is there perhaps any other way to leave a script on the server and still make it work when the page loads?
Any help will be GREATLY appreciated!
PS: Just two more bizarr thoughts... Is it because I put the script into an invisible folder ("_scripts")? Or can there be something particular about the srcipt itself why it won't work when left on server?
gil davis
12-12-2002, 04:45 PM
You might check to see if the underscore character is legal as the first character of a folder name.
Valery
12-12-2002, 07:01 PM
Gil,
thank you so much for your reply!
Hmmm... How do I check it?
There are several folders on my server whose names start with an underscore... So I decided to create my own and thus make the script just as invisible as the folder itself.
Thank you again!
Digime
12-12-2002, 07:13 PM
open your brower's error report, the brower will show some error info
hfraser
12-12-2002, 11:07 PM
ok an invisible folder is something that is not accessible from the client side (your browser!) through a web server it is "invisible" meaning that if i point my browser to it i will not be able to see it or see the files in it ... now a .js file is loaded from the client side ... therefore i cannot load becaus i cannot see it !
now what you can do is take the underscore out and voila!
and an other thing !
dont put the <script> tags in your .js just you javascript!
hans!!
Valery
12-13-2002, 05:17 AM
Hans and All,
thank you so much for your help! Removing the underscore really did the trick - the script works now! (Albeit after I put that line <script language="JavaScript" src="../scripts/script_DE.js"> between <server> and </server>).
Please allow me to ask you two more questions:
1) OK, but what if I really wanted to hide the script from prying eyes and make it invisible? Is there a way? If so, how do I do it?
(I heard something about <!--#include file="../_invisible_folder/script.js" --> - is it the way to go?)
2) Also (a little bit off topic), is there a way to leave a table, i.e. everything between <table> and </table> on the server as well so that I can change it only at one place instead of in all documents using one and the same table? And on top of that make the code of the table invisible as well?
Many many thanks again!
Charles
12-13-2002, 05:52 AM
You cannot hide your scripts; the internet doesn't work that way. All the internet can do is send send files or refuse to send files. You can put your file behind a password, but once I have that file there is absolutely nothing that you can do to stop me from doing with it whatever I want. There are some tricks that make it a tiny bit harder for me to figure out where you file is, but those tricks are harder for you in implement than they are for me to foil.
And forgive me for saying this, but you've got a lot nerve even asking how to do such a thing. The web has grown because of the collaborative efforts of the people who built it. And much of that collaboration is peeking under the hood of everybody else's pages. You are asking me to, in the spirit of that collaboration, tell you how to destroy that very collaboration.
Albeit after I put that line <script language="JavaScript" src="../scripts/script_DE.js"> between <server> and </server>
There is no such thing as a SERVER element. You've simply made up some tags that I can assure you are being ignored by your browser. Something else is going on there. You can see the complete list of valid HTML elements, with links to descriptions of their proper use, at http://www.w3.org/TR/html4/index/elements.html.
If you are going to use a table to display data then see http://www.w3.org/TR/html4/struct/tables.html. It takes a lot of work to make tables work with audio and Braille browsers. If you are using tables for layout know that:
Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media. Additionally, when used with graphics, these tables may force users to scroll horizontally to view a table designed on a system with a larger display. To minimize these problems, authors should use style sheets to control layout rather than tables.
Your example above, <!--#include file="../_invisible_folder/script.js" --> is an example of how to 'include' one file into another, but only on some servers. Ask your server people about 'server side includes'. They'll be able to tell you how to get things running properly.
Valery
12-13-2002, 06:23 AM
Charles,
many thanks for your very interesting and detailed reply! Really much appreciated!
Have to run now... Will respond in detail a bit later.
Thanks again!
2) Also (a little bit off topic), is there a way to leave a table, i.e. everything between <table> and </table> on the server as well so that I can change it only at one place instead of in all documents using one and the same table? And on top of that make the code of the table invisible as well?
Yes, Server Side Includes are the way to do this. Charles was right that they only work on some (most) servers. You will use <!--#include file="test.html"--> to do this. You will have to rename all files calling this SSI to .shtml (this lets your server know that you pages us SSI) test.html should be the exact code that is between <table></table>. Don't include code such as <head> or <body> tags in the test.html page. Hope this helps you.
Charles
12-13-2002, 03:36 PM
Originally posted by pyro
Yes, Server Side Includes are the way to do this. Charles was right that they only work on some (most) servers. You will use <!--#include file="test.html"--> to do this. You will have to rename all files calling this SSI to .shtml (this lets your server know that you pages us SSI) test.html should be the exact code that is between <table></table>. Don't include code such as <head> or <body> tags in the test.html page. Hope this helps you. That's how one does it on older versions of the Apache server that hapen to be configured in a particular way. (<!--#include file=""--> has been depricated in favour of <!--#include virtual=""--> and the required file extension is determined by the particular server configuration.) You really need to talk to somebody who knows how your particular server is set up.
Valery
12-14-2002, 05:07 AM
Pyro,
thank you very much your advice on how leave a table on the server - very much appreciated! I will certainly try it out!
Should I then rename ALL my pages to SHTML or only those whose tables are left on the server?
Many thanks again!
-------------------------------------------------------------------------
Charles,
I thank you very much again for your detailed and very intersting reply of yesterday!
Yes, I am very well aware of the principals of openness and collaboration on the Internet. And yes, if not for it, the web would cease to exist - you are absolutely right.
Asking a question here about how to conceal my scripts and tables (neither of which I have written myself - totally new as I am to HTML codes, let alone to JavaScripts) had (still has) one single concern behind it: I have heard that scripts and tables may get corrupted by browsers or - still worse - be hacked by ... whoever. Since these scripts and tables are absolutely vital to my pages, I was thus trying to simply keep them safe on the server.
Again, I have only HEARD about it - whether this (rumour?) is right or wrong, I don't know. I assumed it was right (is it really?) and hence asked here for help to protect my scripts and tables.
Please kindly let me know if this concern of mine is justified or not. If it is, what can I really do to keep my scripts and tables safe from being corrupted by browsers and/or altered by hooligans.
Best regards,
Valery
Charles
12-14-2002, 07:06 AM
The visibility of you scripts has nothing to do with the vulnerability of your site. And nothing you can do will have any effect in that department. That's a server issue; let those people worry about it. And the server people do worry about these things. For instance there was some sort of security problem with the SSI command <!--#include file=""--> which is why it was depricated.
And again, that method that pyro suggested only works on some servers. But, most servers have some method of including files. Nobody here knows what server you are using and how it is configured. Talk to somebody who does know.
If you are using the Apache server and SSI is enabled then the server will be configured to pre-process all files with certain extensions. Most often that extension is '.shtml' but it could be '.html' or anything else. The pre-processing looks for and executes the commands, so you only need to put that extension, whatever it may be, on those files that contain the commands. You do not need to put it on the file that is included, but it doesn't hurt if you do.
Valery
12-14-2002, 08:14 AM
Thank you for your reply, Chareles!
Originally posted by Charles
The visibility of you scripts has nothing to do with the vulnerability of your site. And nothing you can do will have any effect in that department.
But is it true that csripts and e.g. tables can be corrupted by browsers if they are written into the HTML code on the page?
Originally posted by Charles
Nobody here knows what server you are using
It's a Windows NT server (and I am not quite happy with it, to be frank).
Have a lovely weekend!
Valery
Charles
12-14-2002, 08:42 AM
But is it true that csripts and e.g. tables can be corrupted by browsers if they are written into the HTML code on the page?I'm not sure what it is that you are worried about. Browsers don't care where they got your scripts or tables, the're going to do with it what they will. And yes, it is true that some browsers do not understand tables and some present them in different ways. This is why you out never to use them for layout.