HTML Question
Moderators: Big-O Ryan, Big-O Mark, Matt, jester22c
HTML Question
I used a program to make a DHTML menu for my website. I wan't to add it tp every page but it takes up like 600 lines of code. is there a way that i could just save that in a page like menu.html then add somehing to everypage that loads what is at menu.html and adds it to the page.
- Master Jedi
- Guru
- Posts: 1161
- Joined: Sat Jun 15, 2002 10:34 pm
- Contact:
You'll have to change it a little bit. All the html code that you want to appear on every page will have to be put into the script part like
Then you save this file as FILENAME.js and put this in your pages:
Code: Select all
<script>
document.write('<table border="0">');
//the rest of the HTML in document.write's
</script>
Code: Select all
<script language="JavaScript" src="FILENAME.js"></script>
- Master Jedi
- Guru
- Posts: 1161
- Joined: Sat Jun 15, 2002 10:34 pm
- Contact:
It's like this:
Original page:
In script.js:
In your HTML pages:
Original page:
Code: Select all
<script>
//here is your script
</script>
<!-- This is all the HTML that's part of your menu's objects etc. -->
<table border=0>
<tr>
<td>blah</td>
</tr>
</table>
<!-- END of required stuff -->
Code: Select all
//copy and paste the whole script here without the <script> and </script> tags
document.write('<table border=0>')
document.write('<tr>')
document.write('<td>blah</td>')
document.write('</tr>')
document.write('</table>')
Code: Select all
<!-- Put this script tage wherever the code would be on your original web pages. If the script has bits and pieces in different parts of the page, you may nees more than one JS file -->
<script language="JavaScript" src="script.js"></script>
<!-- The page content goes here -->
Who is online
Users browsing this forum: No registered users and 0 guests