PDA

View Full Version : tabset script


jcochran
08-27-2002, 10:35 PM
I am new at using JavaScript, bascially self taught.,so please bear with me. It is not like I am foreign to programming, but it has been some time - (worked with COBOLT a long time ago). Know HTML and have developed websits using FrontPage.

I have gone through the tutorials on your web site and read several web books on JavaScript, All show various sample script, which I can generally get to work. As I am becoming more involved in web design, I get confused in determing which part of the java code goes in the <Head> section and which goes in the <Body>.

I saw a tabset menu component which I would like to try to my web site, but need some help. I'm also not very familiar with using JavaScript Libraries? I read the creating and referencing external JavaScript libraries and it seems pretty straight forward. Is there a way I can test the .js file actions before I go live? Will most commercial hosting servers allow you to upload the .js files and should they be in a separarte place, hidden? How do you test this type of component befor you go live. Can it be tested on your local system first?

I know all the information is there but am not sure where to start.

Could you give me some advice.

beetle
08-27-2002, 10:56 PM
Well, since Javascript is totally client-side, then you can test it on any machine with a decent web-browser. The '.js' files can be placed anwhere amongst your site structure, although if you have several, it is wise to create a separate subfolder for them. I usually just use the folder name 'js' (example? <script src="/js/script1.js"></script>)


As far as separating code from the body vs the head, here are some things you should know If the javascript needs to access objects on the page, those objects need to be loaded first. Source order plays a role here (must appear in the HTML before it's used/accessed), otherwise access functions with the body's onload() method
Any script that actively writes to the page on page load needs to be in the body (note: there may be a funciton in the HEAD that does the actual writing, but the function call needs to be in the BODY)
If it can be put in the HEAD w/o causing problems, do it. Keep as much scripting out of the BODY as possible.