OK! I gave it away in the title.
.
What I have is a java script that is the floating top menu for the site.
Instead of putting all that code on each page I want to have it on one page and just use a little code to import it on all the other pages.
.
I just did this with the header & footer in php but this page is a .js and I don't know how to tell the pages how to link to it.
.
It is after midnight & I have school in the morning & need to get up at 05:00 so I'll check responses by E-Mail.
.
Thanks in advance.
Den

Recommended Answers

All 9 Replies

PLEASE don't forget that I am just a student and VERY new at this.
Just to let you know this script is now being used on this page:
http://www.terri-lizardlady.com
This is the page that I am working on to create a new site because the old site was created with (don't gag now) FrontPage.
http://terri-lizardlady.com/test/blank_template.php
I have a few problems:
#1 when I loaded the script on the page it showed an error on line 3
.
#2 w3schools has this notice:

JavaScript can also be placed in external files.
External JavaScript files often contain code to be used on several different web pages.
External JavaScript files have the file extension .js.
Note: External script cannot contain the <script></script> tags!
To use an external script, point to the .js file in the "src" attribute of the <script> tag:

My code on the page is:

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

Here is the code on menu.js

// JavaScript Document
<style>
all
.clsMenuItemNS, .clsMenuItemIE{text-decoration:none; font:bold 12px Arial; color:#cab774; cursor:hand; z-index:200;}
#MainTable A:hover {color: #cab774;}

.Header 
{
}

#header 
{
background:url('http://www.blogblog.com/scribe/divider.gif') no-repeat bottom left;
}

#header .widget 
{
margin-bottom:12px;
padding-bottom:12px;
}

h1 
{
margin:0;
padding-top:0;
padding-right:0;
padding-bottom:6px;
padding-left:0;
font: normal normal 225% Georgia, Times New Roman,sans-serif;
color: #956839;
}

.med{font-size:medium;font-weight:normal;padding:0;margin:0}#res{padding-right:1em}ol li{list-style:none}.g{margin:1em 0}li.g{font-size:small;font-family:arial,sans-serif}.s{max-width:42em}</style>
 
<script language="JavaScript"> 
 
//Top Nav Bar I v2.1- By Constantin Kuznetsov Jr. (script@esolutiononline.com) 
//Modified by Dynamic Drive for NS6/Opera6 compatibility and code streamlining March 4th, 2002
//Visit http://www.dynamicdrive.com for this script
 
var keepstatic=1 //specify whether menu should stay static 0=non static (works only in IE4+)
var menucolor="000000" //specify menu color
var submenuwidth=270 //specify sub menus' color
 

</script>

<!--[if !mso]>
<style>
v\:*         { behavior: url(#default#VML) }
o\:*         { behavior: url(#default#VML) }
.shape       { behavior: url(#default#VML) }
div.Section1
	{page:Section1;}
</style>
<![endif]--><!--[if gte mso 9]>
<xml><o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml><![endif]-->

<script type="text/javascript">

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

You can't use the style in js file. js file only accept javascript code. so cut off your style from menu.js

Not sure what you are saying here.
.
Are you saying that I should remove just the

<style></style>

codes or are you saying to remove the entire style and put that on the CSS page?
.
As you can see by looking at the script (below) there are two (2) styles listed.

Remove the entire style and no need of

<script type="text/javascript"></script>
<script type="text/javascript"></script>

tags in js file

I have tried many things and that was one.
Nothing seems to be working so I am going to change things around and put in a sidebar with links instead.
It's unfortunate because I use that menu on other sites and it works really well.
When I install it on the page and check it with w3code checker I get all kinds of errors anyways - even though it works beautifully.
That's OK!
The more I go to school the more I will learn and one day I will redo the site once more.
Thanks for your time anyways.
Den

put your javascript in a .js file, and your styles and layouts in a .css file.
you can them import them with a single line of code in each html file you want.

Member Avatar for stbuchok

Daitken, if you really want to learn this stuff, learn to do it right, even if it takes days or weeks to understand.

I already have a CSS page for general use.
Would I need a separate CSS that would just relate back to this script then?
I mean, no biggie I can do it. I'm just wondering if that is what you are talking about.
When I come home from school or this weekend (homework first you know) I will try your idea.
I really appreciate all the help I am getting with this problem.
I may be a little thick but that just comes with old age and that I am new at all this.
However, I am learning and it's fun!
BTW
If anyone wants to see the site here is the original I made two months ago for my better half: http://www.terri-lizardlady.com
Here is the new test site I am working/learning on: http://www.terri-lizardlady.com/test/blank_template.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.