Link to home
Start Free TrialLog in
Avatar of djdiablo
djdiablo

asked on

How to insert a load of Javascript as an object into html?

Hi, I have created a menu bar in a neat little Javascript program but it requires me to insert a large amount of script into each html file in order to see it.

This is in the header:
<code>
<script type="text/javascript" language="JavaScript1.2" src="stm31.js"></script>
</code>

And I have to use ALL of this code where I want the menu:
<code>
  <!-- MENU BAR STARTS-->
    <script type="text/javascript" language="JavaScript1.2">
<!--
beginSTM("menu1113129675","static","0","0","none","false","true","310","1000","0","250","","blank.gif");
beginSTMB("auto","0","0","horizontally","dropdown/arrow_r.gif","7","7","0","3","#ffffff","","tiled","#000000","1","solid","0","Normal","50","0","0","7","7","0","0","2","#7f7f7f","true","#000000","#000000","#000000","complex");
appendSTMI("false","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Home","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","index.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","index.htm","","","tiled","tiled");
appendSTMI("true","Menu&nbsp;Item&nbsp;1","left","middle","line2.gif","line2.gif","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
appendSTMI("false","Facilities","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
beginSTMB("auto","0","0","vertically","dropdown/arrow_r.gif","0","0","0","3","#ffffff","","tiled","#000000","1","solid","0","Normal","50","0","0","0","0","0","0","0","#7f7f7f","false","#000000","#000000","#000000","none");
appendSTMI("false","On&nbsp;Site&nbsp;Facilities","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","facilities.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","facilities.htm","","","tiled","tiled");
appendSTMI("false","Cafe","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","cafe.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","cafe.htm","","","tiled","tiled");
endSTMB();
appendSTMI("true","Menu&nbsp;Item&nbsp;2","left","middle","line2.gif","line2.gif","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
appendSTMI("false","Events","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
beginSTMB("auto","0","0","vertically","dropdown/arrow_r.gif","0","0","0","3","#ffffff","","tiled","#000000","1","solid","0","Normal","50","0","0","0","0","0","0","0","#7f7f7f","false","#000000","#000000","#000000","none");
appendSTMI("false","Events&nbsp;Timetable","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","events.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","events.htm","","","tiled","tiled");
appendSTMI("false","Triathlon","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","triathlon.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","triathlon.htm","","","tiled","tiled");
endSTMB();
appendSTMI("true","Menu&nbsp;Item&nbsp;3","left","middle","line2.gif","line2.gif","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
appendSTMI("false","Your&nbsp;Visit","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
beginSTMB("auto","0","0","vertically","dropdown/arrow_r.gif","0","0","0","3","#ffffff","","tiled","#000000","1","solid","0","Normal","50","0","0","0","0","0","0","0","#7f7f7f","false","#000000","#000000","#000000","none");
appendSTMI("false","Opening&nbsp;Times","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","times.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","times.htm","","","tiled","tiled");
appendSTMI("false","Entrance&nbsp;Prices","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","prices.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","prices.htm","","","tiled","tiled");
appendSTMI("false","Find&nbsp;Us","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","findus.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","findus.htm","","","tiled","tiled");
appendSTMI("false","Weather&nbsp;Forecast","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","weather.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","weather.htm","","","tiled","tiled");
endSTMB();
appendSTMI("true","Menu&nbsp;Item&nbsp;3","left","middle","line2.gif","line2.gif","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
appendSTMI("false","Features","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
beginSTMB("auto","0","0","vertically","dropdown/arrow_r.gif","0","0","0","3","#ffffff","","tiled","#000000","1","solid","0","Normal","50","0","0","0","0","0","0","0","#7f7f7f","false","#000000","#000000","#000000","none");
appendSTMI("false","Photo&nbsp;Gallery","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","gallery.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","gallery.htm","","","tiled","tiled");
appendSTMI("false","Heritage","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","Coming&nbsp;Soon!","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
endSTMB();
appendSTMI("true","Menu&nbsp;Item&nbsp;3","left","middle","line2.gif","line2.gif","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
appendSTMI("false","Contact","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","","","","tiled","tiled");
beginSTMB("auto","0","0","vertically","dropdown/arrow_r.gif","0","0","0","3","#ffffff","","tiled","#000000","1","solid","0","Normal","50","0","0","0","0","0","0","0","#7f7f7f","false","#000000","#000000","#000000","none");
appendSTMI("false","Contact&nbsp;Us","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","contact.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","contact.htm","","","tiled","tiled");
appendSTMI("false","Email&nbsp;Group","left","middle","","","-1","-1","0","normal","#3399ff","#3399ff","","1","-1","-1","blank.gif","blank.gif","-1","-1","0","","emailgroup.htm","_self","Arial","8pt","#ffffff","bold","normal","none","Arial","8pt","#ffff00","bold","normal","none","0","none","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","#ffffff","emailgroup.htm","","","tiled","tiled");
endSTMB();
endSTMB();
endSTM();
//-->
        </script>
</code>

Is there any way that I can save all of that Javascript into a separate file and simply insert an object or pointer to it? I have loads of html files which use the same menu bar but every time I update the menu, it's an absolute nightmare. Ideally I would just update one file.

I don't want to use frames due to the layout of the page.

Thanks for your assistance!
ASKER CERTIFIED SOLUTION
Avatar of German_Rumm
German_Rumm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djdiablo
djdiablo

ASKER

Thanks, don't know why I didn't think of that. Nice one!