View Full Version : can navbar script be an include file?
johnstonmark
11-26-2002, 08:46 PM
I have a javascript navbar dropdown programmed for my site. Can I put it as an include file so that I don't have to isert the script on every page? What is the best way to do it? Thanks!
chrismiceli
11-26-2002, 09:07 PM
put it in a frame mabey?
brothercake
11-26-2002, 09:23 PM
put the code (everything except the <script> tags) in an external .js file, and then reference that on each page:
<script language="javascript" type="text/javascript" src="/menu_script.js"></script>
Yes, an include should work fine as long as your server supports them. I usually put the script in one file and the menu html in a separate include file. Here's a quick example of how I put them into a page:
<html>
<head>
<title>Include Example</title>
<script type="text/javascript" src="menuScript.js"></script>
</head>
<body>
<!-- #include file="menu.html" -->
</body>
</html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.