server relative paths for the .js files?
server relative paths for the .js files?
hi all.
Other people have asked this as well, but either have not gotten a response, or not gotten one that has worked for me.
I am currently running RC3 because RC4 added some odd boxes around my menus.
My problem is that I cannot seem to get the src link right when I put my .js files in a different folder than my .html (.php) files
Right now I have <SCRIPT language=JavaScript src="/home/me/public_files/java/milonic_src.js" type=text/javascript></SCRIPT>
I have tried every variation on that I can think of, including trying src="http://......"
Anyone have any ideas?
Other people have asked this as well, but either have not gotten a response, or not gotten one that has worked for me.
I am currently running RC3 because RC4 added some odd boxes around my menus.
My problem is that I cannot seem to get the src link right when I put my .js files in a different folder than my .html (.php) files
Right now I have <SCRIPT language=JavaScript src="/home/me/public_files/java/milonic_src.js" type=text/javascript></SCRIPT>
I have tried every variation on that I can think of, including trying src="http://......"
Anyone have any ideas?
relative paths
I added this to my global.js file for my site, and it worked. I use a global.js file to store many other (non-menu) things regarding the site:
above local and live variables are test or production servers, then a live server
Further down you'll need to add the path to each img tag and url, e.g.
it's working for me at all tiers
Hope that helps,
Cubefree
Code: Select all
<script language="javascript" src="scripts/global.js"></script>
// Remove any frames
if (top.location != self.location) {
top.location = self.location;
}
var url = self.location.href;
url = url.toLowerCase();
// determine the server
var DOM = '';
var local = 'website/';
var live = 'prototype/';
((url.lastIndexOf(local) > 1) ? DOM = local : DOM = live )
// determine relpath, section of site and subdirectory variable
var endOfDOM = url.lastIndexOf(DOM);
var endOfURL = url.substring((endOfDOM + DOM.length), url.length);
// determine relpath, section of site and subdirectory variable
var path = '';
for (i=0; i<endOfURL.length; i++) {
if (endOfURL.charAt(i)=='/') { path += '../'; }
}
Further down you'll need to add the path to each img tag and url, e.g.
Code: Select all
path+"images/nav/cmm_arrow2_off.gif" // and
"<img src="+path+"images/nav/proginfo_off.gif width=150 height=23 border=0>","show-menu=proginfo",path+"proginfo/default.htm swapimage="+path+"images/nav/proginfo_on.gif;offfunction=undefined;","Program Information",1
Hope that helps,
Cubefree
Re: server relative paths for the .js files?
Same thing happened to me. Turned out I had some border settings wrong. Check your array code carefully (it worked the way it was under RC3, even though the code was wrong).Twill wrote:I am currently running RC3 because RC4 added some odd boxes around my menus.
scriptpath=""; does nothing more than point to the directory that contains the menu files.My problem is that I cannot seem to get the src link right when I put my .js files in a different folder than my .html (.php) files
If that is supposed to be your scriptpath=""; (which your message flow seems to indicate) it is entirely wrong. Andy gives an example right in the code. Following what you have written you should have scriptpath="/home/me/public_files/java/";Right now I have <SCRIPT language=JavaScript src="/home/me/public_files/java/milonic_src.js" type=text/javascript></SCRIPT>
John
cubefree, that looks a lot more confusing that I had hoped for...I have no idea what a global.js file is :-p
jgillett , I dont know where this scriptpath""; thing came from or what it is. I looked in the examples for this code, but couldnt find one.
Are you saying that my html should look more like:
<html>
<head></head>
<body>
<SCRIPT language=JavaScript scriptpath="/home/me/public_files/java/" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="my_array.js" type=text/javascript></SCRIPT>
</body>
</html>
because I dont really know where to put this scriptpath.
sorry for being dense
I have looked, and tried to fix it myself.
jgillett , I dont know where this scriptpath""; thing came from or what it is. I looked in the examples for this code, but couldnt find one.
Are you saying that my html should look more like:
<html>
<head></head>
<body>
<SCRIPT language=JavaScript scriptpath="/home/me/public_files/java/" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="my_array.js" type=text/javascript></SCRIPT>
</body>
</html>
because I dont really know where to put this scriptpath.
sorry for being dense

No no, there is code in your webpage that references the milonic_src file. You need to correctly specify where your page should look for that. Then you also need to reference the menuarray.js file from your page as well using the correct path. I.E...
What this does is first imports MILONIC_SRC into your page and executes it. Inside of milonic_src, there is a variable at the top called scriptpath...this variable tells milonic_src how to import the correct menu code (it decides based on your browser), but it needs a path to your menus directory because as far as its concerned, the code at that point is executing in the same directory as your webpage and will look in that directory if its not specified, so you should put that in here as well. I.E.
This way, the right menu code will be imported from ...com/home/me/public_files/java/menudom.js or whatever. Your page then will import the menu_array.js page from that same directory because you wrote it out in your page.
Hope this helps some. I tried to step out the process of what its doing, and I hope I didnt confuse you.
Code: Select all
<SCRIPT language=JavaScript src="http://www.yourdomain.com/home/me/public_files/java/milonic_src.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="http://www.yourdomain.com/home/me/public_files/java/menu_array.js" type=text/javascript></SCRIPT>
Code: Select all
scriptpath="http://www.yourdomain.com/home/me/public_files/java/"
Hope this helps some. I tried to step out the process of what its doing, and I hope I didnt confuse you.
Dave Hergert
Software Engineer
"Helping to make the menu better, one
at a time."
Software Engineer
"Helping to make the menu better, one

-
- Beginner
- Posts: 2
- Joined: Mon Aug 11, 2003 9:28 am
Hello and thanks for the thread postings. I have a personal site with the new horizontal menu located at http://www.keyway.net/~lan/menu. I have the html code on the page as follows...
<html>
<head>
<SCRIPT language=JavaScript src="http://www.keyway.net/~lan/menu/milonic_src.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="http://www.keyway.net/~lan/menu/horizontal_data.js" type=text/javascript></SCRIPT>
</head>
<body scroll=auto >
</body>
</html>
I also have a page located at
http://www.keyway.net/~lan/menu/test/index.html
It has the same html code pointing to the same path but does not display the menu. Can someone please explain to me what I have done wrong to disable the page in the test folder from working and PLEASE how to resolve this .
In advance I thank you for yout assistance.
Dick W-
<html>
<head>
<SCRIPT language=JavaScript src="http://www.keyway.net/~lan/menu/milonic_src.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="http://www.keyway.net/~lan/menu/horizontal_data.js" type=text/javascript></SCRIPT>
</head>
<body scroll=auto >
</body>
</html>
I also have a page located at
http://www.keyway.net/~lan/menu/test/index.html
It has the same html code pointing to the same path but does not display the menu. Can someone please explain to me what I have done wrong to disable the page in the test folder from working and PLEASE how to resolve this .
In advance I thank you for yout assistance.
Dick W-
I just took a look at both sites and they both displayed menus, so I am assuming you figured it out. My guess was you had a problem with your script path variable not being set to the correct directory even though your HTML code was dead on. Best of luck from here forward.
Dave Hergert
Software Engineer
"Helping to make the menu better, one
at a time."
Software Engineer
"Helping to make the menu better, one

The structure of my site is
http://www.sitename.com
.....htdocs
........root
........libs
..........navbars
.............menu.inc.php
(root and libs are on the same level, but navbars is below libs)
The code in menu.inc.php is:
Portion of index.php:
I also have tried prefixing the milonic_src.js, mmenuns4.js, and mmenudom.js files with all forms of:
http://www.sitename.com/libs/navbars/
/libs/navbars/
/navbars/
and even...http://www.sitename.com/htdocs/libs/navbars/ (though htdocs should not be necessary since this is root).
However, unless I place all files into the directory fron which a menu is called I get a JS error that indicates that the milonic_source.js file (and other js files) was not found pointing to the directory from which the script is run. Indeed if I place the three js files in the directories from which the script is run the menu works. However the relative path seems to be ignored.
I am NOT the original author of the site but now am charged with maintaining it. I presume the line in index.php:
Anyone have a method that can be used to fix this problem? AAARRRAAAGGGHHHH!
BTW since the site on which this is located is password protected if you need the URL I will have to set up a temporary login and password.
http://www.sitename.com
.....htdocs
........root
........libs
..........navbars
.............menu.inc.php
(root and libs are on the same level, but navbars is below libs)
The code in menu.inc.php is:
The menus is called by index.php in "htdocs"<script type="text/javascript" src="http://www.protonic.com/libs/navbars/mi ... "></script>
<param copyright="JavaScript Menu by Milonic - http://milonic.com"></param>
<script type="text/javascript">
<!--
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=http://www.protonic.com/libs/navbars/mm ... /scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=http://www.protonic.com/libs/navbars/mm ... /scr"+"ipt>");
-->
</script>
type=text/javascript></SCRIPT>
?>
</head>
<body>
<script language=javascript>
<?
include("$DOCUMENT_ROOT/libs/navbars/menu_data.js.php");
?>
</script>
Portion of index.php:
"DOCUMENT_ROOT" above = 'http://www.sitename.com"<?
if ($frames) {
?>
<html>
<head>
<title>pagename</title>
</head>
.
.... No frames message
.
} else if (!$index) {
?>
<script language="javascript">
<!--
top.location.href='http://www.sitename.com/root/index.php?frames=true';
//-->
</script>
<?
exit;
}
?>
...........html code......
<?
require("$DOCUMENT_ROOT/libs/navbars/menu.inc.php");
?>
..........more HTML code....
I also have tried prefixing the milonic_src.js, mmenuns4.js, and mmenudom.js files with all forms of:
http://www.sitename.com/libs/navbars/
/libs/navbars/
/navbars/
and even...http://www.sitename.com/htdocs/libs/navbars/ (though htdocs should not be necessary since this is root).
However, unless I place all files into the directory fron which a menu is called I get a JS error that indicates that the milonic_source.js file (and other js files) was not found pointing to the directory from which the script is run. Indeed if I place the three js files in the directories from which the script is run the menu works. However the relative path seems to be ignored.
I am NOT the original author of the site but now am charged with maintaining it. I presume the line in index.php:
is causing this problem. However this seems to be needed for authentication of the site.top.location.href='http://www.protonic.com/techs/index.php?frames=true';
Anyone have a method that can be used to fix this problem? AAARRRAAAGGGHHHH!


BTW since the site on which this is located is password protected if you need the URL I will have to set up a temporary login and password.