PDA

View Full Version : Includes



NewsGuy
12-03-2008, 10:51 PM
1) Script Title: Chrome CSS Drop Down Menu (v2.5)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/chrome/index.htm

3) Describe problem: I've built my nav and am trying to include it on my website via a server side include tag. Is that possible?

ddadmin
12-04-2008, 12:08 AM
I don't see why not. SSI basically is as if you're manually including the script onto your pages...

NewsGuy
12-04-2008, 11:49 AM
That's what I thought, but I can't get it to work properly. I really don't want to get into a situation where making a change to the nav involves me going in and editing every single page.

molendijk
12-04-2008, 12:08 PM
If you cannot get SSI to work on your server, you can use javascript:


if(window.opera)
{document.write('<iframe src="menu.html" width="0" height="0" name="menu" ></iframe>');}
else document.write('<object type="text/html" data="menu.html" width="0" height="0" name="menu" ></object>');
function extractMenu(){
try{
document.body.innerHTML+=window.frames['menu'].body.innerHTML;
}
catch(e){
document.body.innerHTML+=window.frames['menu'].document.body.innerHTML;
}
}
window.onload=extractMenu;

where 'menu.html' contains your menu.
===
Arie Molendijk.

NewsGuy
12-04-2008, 12:58 PM
Pardon my ignorance of JavaScript, but where do I put that code in the HTML? Is it where I want the menu to show up or in the <HEAD>. Again, sorry for my ignorance, but thanks for the help!

molendijk
12-04-2008, 02:55 PM
In the head:


<head>
<script type="text/javascript">
if(window.opera)
{document.write('<iframe src="menu.html" width="0" height="0" name="menu" ></iframe>');}
else document.write('<object type="text/html" data="menu.html" width="0" height="0" name="menu" ></object>');
function extractMenu(){
try{
document.body.innerHTML+=window.frames['menu'].body.innerHTML;
}
catch(e){
document.body.innerHTML+=window.frames['menu'].document.body.innerHTML;
}
}
window.onload=extractMenu;
</script>
</head>


You can specify the position of the menu in menu.html.
===
Arie.

ddadmin
12-05-2008, 06:30 AM
That's what I thought, but I can't get it to work properly. I really don't want to get into a situation where making a change to the nav involves me going in and editing every single page.

I'd still recommend using SSI instead of JavaScript to include the contents of a file, be it this script or some random HTML. What do you have so far? Have you verified first that SSI in general works on your site?

molendijk
12-05-2008, 12:14 PM
Perhaps you tested SSI locally, on your hard disk only? That would explain why it does not seem to work with you. (You have to test it online).
===
Arie.

NewsGuy
12-05-2008, 01:00 PM
SSI works and is being used on the page. I build the nav here: http://wcsi.whiterivernews.com/matt/nav2.html and tried to include it here: http://wcsi.whiterivernews.com/matt/testpage2.asp.

ddadmin
12-05-2008, 10:26 PM
Comparing the source of the two images, it seems the later, non working one is missing the .css file reference:


<link rel="stylesheet" type="text/css" href="http://wcsi.whiterivernews.com/matt/nav/chromestyle2.css" style="padding: 0" />

Simply do a compare to see what else is missing if the above doesn't fix things.

NewsGuy
12-05-2008, 10:31 PM
That did it! Awesome! Thanks!