HTML Question

Hardware, Software, Internet, etc.

Moderators: Big-O Ryan, Big-O Mark, Matt, jester22c

Post Reply
BigHead
Fanatic
Fanatic
Posts: 127
Joined: Thu Nov 14, 2002 8:25 pm
Location: somewere in the USA
Contact:

HTML Question

Post by BigHead »

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.
User avatar
Master Jedi
Guru
Guru
Posts: 1161
Joined: Sat Jun 15, 2002 10:34 pm
Contact:

Post by Master Jedi »

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

Code: Select all

<script>
document.write('<table border="0">');
//the rest of the HTML in document.write's
</script>
Then you save this file as FILENAME.js and put this in your pages:

Code: Select all

<script language="JavaScript" src="FILENAME.js"></script>
BigHead
Fanatic
Fanatic
Posts: 127
Joined: Thu Nov 14, 2002 8:25 pm
Location: somewere in the USA
Contact:

Post by BigHead »

could u give me a example of were the HTML would go
User avatar
Master Jedi
Guru
Guru
Posts: 1161
Joined: Sat Jun 15, 2002 10:34 pm
Contact:

Post by Master Jedi »

It's like this:

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 -->
In script.js:

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>')
In your HTML pages:

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 -->
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests