PDA

View Full Version : slashdot html files in folders not finding js script



port4u
10-12-2006, 12:19 PM
Slashdot menu
http://www.dynamicdrive.com/dynamicindex1/slashdot.htm

I am using the slashdot menu on my test site and I can get it to work with the slashdot html files in the root and then seeking the js script in another folder. When I make a sub directory iwith more html files they no longer find the *.js script. Is there a way to use only one *js file and have all the html files find it no matter what the folder structure is. I am assuming there is a way to modify all the html files to search for the *js file in one location on the site.
Right now the script in the header of my html m=pages lookes like this:
<script language="JavaScript" type="text/javascript" src="../scripts/dahlgren.js"></script>
<script language="JavaScript" type="text/javascript">

I modified the JS links to the files need for th emenu. That is part of the problem. The html files need to find the images.
Here is a sample of the script for that: function slash_expandall(){
if (typeof menu!="undefined"){
for(i=0; i<Math.max(titles.length, submenus.length); i++){
titles[i].className="title";
arrows[i].src = "menu_files/expanded.gif";
submenus[i].style.display="";
submenus[i].style.height = heights[i]+"px";
}
}
}

function slash_contractall(){
if (typeof menu!="undefined"){
for(i=0; i<Math.max(titles.length, submenus.length); i++){
titles[i].className="titlehidden";
arrows[i].src = "menu_files/collapsed.gif";
submenus[i].style.display="none";
submenus[i].style.height = 0;
}
}
}


At the moment I made a messy work arround. I duplicated the JS file and the menu files and put those in the other directories that the other html files are in. :(

ddadmin
10-12-2006, 07:57 PM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question. Please also put some effort into formating your post/ code.

Regarding your question, just make sure the references to any file within the .js file, including the .js file itself, are aboslute URLs:


<script language="JavaScript" type="text/javascript" src="http://www.mysite.com/scripts/dahlgren.js"></script>

and:


function slash_expandall(){
if (typeof menu!="undefined"){
for(i=0; i<Math.max(titles.length, submenus.length); i++){
titles[i].className="title";
arrows[i].src = "http://www.mysite.com/menu_files/expanded.gif";
submenus[i].style.display="";
submenus[i].style.height = heights[i]+"px";
}
}
}

function slash_contractall(){
if (typeof menu!="undefined"){
for(i=0; i<Math.max(titles.length, submenus.length); i++){
titles[i].className="titlehidden";
arrows[i].src = "http://www.mysite.com/menu_files/collapsed.gif";
submenus[i].style.display="none";
submenus[i].style.height = 0;
}
}
}

and so on. There may be other references you have to locate and change to absolute URLs...

DimX
10-12-2006, 08:13 PM
Also the new version (http://www.dynamicdrive.com/forums/showpost.php?p=48463&postcount=31) has images directory variable (so you don't have to find all the srcs in the js file)

port4u
10-14-2006, 10:41 AM
I do not have an absolute URL yet becasue the the script is not on a website yet. I am new at this. I am not sure how you want me to correct my posting or correct the script. Is there any way to get different files in different folders to all find the same script in a local setting? I am unable to uplaod the site onto a website at this time.
The links in the *.js script are presently as stated in my post. I have html files in the root and in three subfolders that need to call all the *.js files and image files that are in in two other sub folders.
I can get the files in the root working, but then the menus in the subfolders will not work. If I get the ones in the subfolders to call the files the menus in the root files stop working.
Is there some expression that will allow all the files to call the same *js script? Am I misunderstading something about how the *.js has to work?

port4u
10-16-2006, 10:55 AM
Nope. I have not gotten this to work yet. I am using the new files for the slashdot menu. The link to the *.js file in the html files is the proiblem.
Here is what it says in working html files that are in the root.....

<link rel="stylesheet" href="scripts/dahlgren.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="menu_files/dahlgren.js"></script>
<script language="JavaScript" type="text/javascript">

I have other html files in other directories and I want them to find the *.js and *.css file. When I attempt to make the menu work by changing the path and add "../" like this....

<link rel="stylesheet" href="../scripts/dahlgren.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="../menu_files/dahlgren.js"></script>
<script language="JavaScript" type="text/javascript">

the slashdot menu still does not function. However, the *.css file does. Adding "../" to the file path does not make the html file find the *.js scrpt file. I hope I am explaining this well enough. In adition to that I have tried to change the paths to the images in the *.js script. that does not work either.

I want to find a way to only have one *.js script, one set of images for the menu, and one *.css file for my entire site. Is that possible?