By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,689 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,689 IT Pros & Developers. It's quick & easy.

DIV

P: n/a
Hello,

I am not sure if I need Javascript for this:

I have a page with one DIV on the left (menu), and other on the right,
with the content.

I want just one page for the menu code, but that it appears en every
subpages. So How can I put a html file inside a DIV?

Dec 1 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ASM
Winston a écrit :
Hello,

I am not sure if I need Javascript for this:
You don't need it but you can use it if you add a normal link to a page
with this menu for those who haven't JavaScript.

In your pages :

1) in head, call to the JS file which will write the menu :
<script type="text/javascript" src="/js/menu.js"></script>

2) in body at place of your menu :
<noscript>
<p><a href="menu.htm">help navigation</a></p>
</noscript>
<script type="text/javascript">
menu();
</script>

3) rest to write the external file 'menu.js' :

function menu()
{
document.write(
'<div id="menu">' +
'<a href="p1.htm">page 1<\/a><br>' +
'<a href="p2.htm">page 2<\/a><br>' +
'<a href="p3.htm">page 3<\/a><br>' +
'<\/div>'
};
}
I want just one page for the menu code, but that it appears en every
subpages. So How can I put a html file inside a DIV?
You can also try tag 'object' :

<object data="menu.html" type="text/html" width="300" height="200">
alt : <a href="menu.html">help (menu)</a>
</object>
What about to try SSI ? :

1) extensions of files needing SSI are usually : *.shtml
2) make your menu in a separate file ie : menu.txt
(copy-paste only its div and content)
3) in your pages, in place of div menu :
<!--#include virtual="menu.txt -->
4) Save your pages with menu in *.shtml
5) verify all your links and delete from their urls the extensions
of files (if you sure to have only one file with this name in
same folder). The server doesn't need to know these extensions.

This include works only on a server.
Server must have SSI actived.

http://httpd.apache.org/docs/2.0/howto/ssi.html
tuto in french :
http://www.scarabee.com/TRANCHES/SSI/publicvise.shtml

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 1 '06 #2

P: n/a

What about to try SSI ? :

1) extensions of files needing SSI are usually : *.shtml
2) make your menu in a separate file ie : menu.txt
(copy-paste only its div and content)
3) in your pages, in place of div menu :
<!--#include virtual="menu.txt -->
4) Save your pages with menu in *.shtml
5) verify all your links and delete from their urls the extensions
of files (if you sure to have only one file with this name in
same folder). The server doesn't need to know these extensions.

This include works only on a server.
Server must have SSI actived.
Ok, I like SSI for this.

The problem is that menu.txt will have javascript code. Is possible to
put in menu txt a head and script tag with some functions?
Dec 4 '06 #3

P: n/a
ASM
Winston a écrit :
>>
Ok, I like SSI for this.

The problem is that menu.txt will have javascript code.
and ?
Is possible to
put in menu txt a head and script tag with some functions?
JS has not absolutely to be in head

Please no more than one head in a page
(but probably not important as soon as tag 'body' is read by browser)

If you absolutely want your JS menu in head put it in a separate file and

<script src="menu.js" type="text/javascript"></script>
</head>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.