DIV

W

Winston

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?
 
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
 
W

Winston

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?
 
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top