IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Putting the loader code in an external .js file, external javascript .s file
netgate
post Apr 29 2010, 10:47 AM
Post #1


Newbie
*

Group: Members
Posts: 1
Joined: 27-April 10
From: Atlanta
Member No.: 9,755



To get xhtml validation for my client I need to put the loader code for my menus in an external file. This I have done by putting in the header the link to the file

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

The menuloader.js file looks like this:

---------------------------------------------------------------------------------------------------
<script language="javascript" type="text/javascript">
var rimPath=null;var rjsPath=null;var rPath2Root=null;function InitRelCode(){var iImg;var jImg;var tObj;if(!document.layers){iImg=document.images['dmbif'];jImg=document.images['dmbjs'];tObj=jImg;}else{tObj=document.layers['dmbri'];if(tObj){iImg=tObj.document.images['dmbif'];jImg=tObj.document.images['dmbjs'];}}if(!tObj){window.setTimeout("InitRelCode()",700);return false;}rimPath=_gp(iImg.src);rjsPath=_gp(jImg.src);rPath2Root=rjsPath+"../";return true;}function _purl(u){return xrep(xrep(u,"%%REP%%",rPath2Root),"\\","/");}function _fip(img){if(img.src.indexOf("%%REL%%")!=-1) img.src=rimPath+img.src.split("%%REL%%")[1];return img.src;}function _gp(p){return p.substr(0,p.lastIndexOf("/")+1);}function xrep(s,f,n){if(s) s=s.split(f).join(n);return s;}InitRelCode();
</script>
<script language="javascript" type="text/javascript">
function LoadMenus() {if(!rjsPath){window.setTimeout("LoadMenus()", 10);return false;}var navVer = navigator.appVersion;
if(navVer.substr(0,3) >= 4)
if((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)==4)) {
document.write('<' + 'script language="javascript" type="text/javascript" src="' + rjsPath + 'nsmenu.js"><\/script\>');
} else {
document.write('<' + 'script language="javascript" type="text/javascript" src="' + rjsPath + 'iemenu.js"><\/script\>');
}return true;}LoadMenus();</script>
-----------------------------------------------------------------------------------


In the body of the html document were I want the menu to appear the code looks like this:

<!-- DHTML Menu Builder Loader Code START -->
<div name="dmbri" style="position:absolute;">
<img src="menus/dmb_i.gif" id="dmbif" width="1" height="1" alt="" />
<img src="menus/dmb_m.gif" id="dmbjs" width="1" height="1" alt="" />
</div>
<!-- DHTML Menu Builder Loader Code END -->

I've tried some variations, but nothing works.

An example of what it looks like working (but not with the javascript in an external file) is:
http://www.andygrogan.com/2010/web-content/html/e2.html
I have followed the other postings about this in this forum but I have not been able to find a solution.

I hope some one can help!

Andy Grogan
Go to the top of the page
 
+Quote Post
Bitime
post Jul 2 2010, 12:42 AM
Post #2


New Member
*

Group: Members
Posts: 8
Joined: 16-January 06
Member No.: 2,923



Andy

I work in php so what I do is I make a menu.php that I include just after the body tag - menu code it produces has to be right after body tag. That way if I change my menu I just update one page.


in the footer of all my pages I call <script>LoadMenus()</script>

Dont know if that will help, but there you have it.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 5th September 2010 - 11:26 PM