473,498 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem running function in .js file

Sl1ver
196 New Member
I have a tiny problem.

I have used this function in the HTML page and it works but doesn't when i call it from a js file

HTML CODE
Expand|Select|Wrap|Line Numbers
  1. script language="javascript" src="../js/Menu.js">
  2.  
  3.                     var page1 = window.location.pathname
  4.                     page = setMenuTop(page1);
  5.                     document.write(page);
  6.  
  7. </script>
  8.  
JS CODE
Expand|Select|Wrap|Line Numbers
  1. function setMenuTop(sPath)
  2. {
  3.     var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
  4.     var sPageName = sPage.replace('.aspx', '');
  5.  
  6.     if (sPageName === '100') {
  7.         sPageName = 'Top 100';
  8.     }
  9.     if (sPageName === 'Main') {
  10.         sPageName = 'Home';
  11.     }
  12.  
  13.     return sPageName;
  14. }
  15.  
It does not write any code once the page is loaded and i can't see what i'm doing wrong here.
Sep 28 '11 #1
1 1072
Sl1ver
196 New Member
This problem is solved. I took the main query out of the "head" of the html code but just references my .js page from there and then put all the code i need where i needed it and it worked.
Sep 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
15637
by: Wolfie | last post by:
I'm having a strange problem running a jar file I created using Eclipse. The application works correctly inside the IDE -- it compiles, runs, etc. So I exported it to a jar file and am trying to...
0
1719
by: Peter Bassett | last post by:
I am having a problem running my Java application from a remote folder. My CLASSPATH variable is set to ". ; c:\java" and Path contains c:\java I have an application ListFiles.class in c:\java...
7
2204
by: Christopher Brandsdal | last post by:
Hi! I have a problem running my code on 2000 server and iis5.0. The code runs perfectly on my localhost (xp iis5.1) but when i run it on 2000 server iis5.0 I get this error: ...
1
1921
by: CES | last post by:
All, If anyone has been following my trials over the last week see(Setting up a Web Application on IIS 5.1 and ASP.Net Security Problems). I'm having a problem running a Asp.Net Web...
2
3839
by: Peter Macej | last post by:
I need to run external BAT file and print it's output from my application. I use the following code: Dim prs As New System.Diagnostics.Process() prs.StartInfo.UseShellExecute = False...
0
928
by: kalyanijala | last post by:
Hi There, I have a problem running a VB program. This programs actually reads a DAT file and gives the best CPU time taken to run the program. for example I'm reading files like TN3004, TN3104 ,...
4
1816
by: Michael Malinowski | last post by:
Is there a way to read the directory that the currently running python file is located in? Cheers Mike.
1
2543
by: wavespirit75 | last post by:
Hi, I wrote a program which will use ffmpeg to convert media files. Media files can be converted with this string array being passed in to Runtime.getRunTime().exec: String cmd = {ffmpeg path,...
1
1765
by: sbettadpur | last post by:
hello i am calling .exe file through my php script. i.e. using exec or system command, i am running exe file that exe file will create on txt file which contains who has logged into domain(i.e....
2
10080
by: webguy262 | last post by:
I'm trying to troubleshoot a membership script. The script is attempting to write to a file called .fdaccess. The function that's throwing the error is in a file called htpasswd.php. Here's the...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.