I found a java code for a dropdown menu and they want me to put it in my header. <script language="JavaScript"><!-- function goThere(form){ var linkList=form.selectThis.selectedIndex if(!linkList==""){window.location.href=form.selectThis.options[linkList].value;} } //--></script> Code (markup): Is there another option of using a java code instead of putting it in the header
If you want function/variables to be available anywhere in the document, put them between the <head> tags. But you can put Javascript in <script> tags anywhere within the body tags. BTW, that is Javascript, not Java (Two very different things.)
In an external Javascript document called from the header. It sounds the same, but the Javascript won't get parsed by a spider, which makes your code more readable both from a search engine standpoint and a webmaster standpoint. If you externalize your Javascript, you can call it from anywhere you want. You just won't be able to call your functions until after you call your JScript (hence the reason putting it in the <head></head> area is a good thing.) Something like this: <head> <script type="text/javascript" src="your_script_here.js"> <!-- //--> </script> </head> ... ... ... <script type="text/javascript"> <!-- someFunctionFromYourScriptAbove(); //--> </script> Code (markup): It's a lot easier to read, once you're used to it.