473,508 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to retrieve the homepage filename when filename doesn't exist in URL

Hi!

I've built a dynamic navigation system which compares the filename in
the document URL with the filename in the navigation link in order to
determine which link to highlight as "active".

The problem I have is that the URL returned by document.URL (and
location.href) does not include the filename when I'm sitting on the
homepage. This means that when I compare the nav link with the
document URL, I don't get a match.

Eg:
document.URL and location.href returns "http://mydomain.com/"
The navigation link is "http://mydomain.com/index.html"

How can I find out the current document's filename if I'm sitting on
the homepage and the filename is not specified in the document URL?

Thanks in advance,

--Diarmaid.
Jul 23 '05 #1
4 1687
In article <f1**************************@posting.google.com >, elev43
@yahoo.com enlightened us with...

Eg:
document.URL and location.href returns "http://mydomain.com/"
The navigation link is "http://mydomain.com/index.html"

How can I find out the current document's filename if I'm sitting on
the homepage and the filename is not specified in the document URL?


Make a default. If no filename is specified, it's the home page.

--
--
~kaeli~
Why do people who know the least know it the loudest?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Diarmaid wrote on 12 mei 2004 in comp.lang.javascript:
The problem I have is that the URL returned by document.URL (and
location.href) does not include the filename when I'm sitting on the
homepage. This means that when I compare the nav link with the
document URL, I don't get a match.

Eg:
document.URL and location.href returns "http://mydomain.com/"
The navigation link is "http://mydomain.com/index.html"

How can I find out the current document's filename if I'm sitting on
the homepage and the filename is not specified in the document URL?


lhref = document.URL;
if (/\/$/.test(lhref)) lhref += "index.html";
alert(lhref);

This will also do for all [sub]directories where index.html is the default.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #3

Evertjan. wrote:
Diarmaid wrote on 12 mei 2004 in comp.lang.javascript:

The problem I have is that the URL returned by document.URL (and
location.href) does not include the filename when I'm sitting on the
homepage. This means that when I compare the nav link with the
document URL, I don't get a match.

Eg:
document.URL and location.href returns "http://mydomain.com/"
The navigation link is "http://mydomain.com/index.html"

How can I find out the current document's filename if I'm sitting on
the homepage and the filename is not specified in the document URL?

lhref = document.URL;
if (/\/$/.test(lhref)) lhref += "index.html";
alert(lhref);

This will also do for all [sub]directories where index.html is the default.


Sometimes, default.htm, default.asp can also be used



Jul 23 '05 #4
Balaji. M. wrote on 12 mei 2004 in comp.lang.javascript:
lhref = document.URL;
if (/\/$/.test(lhref)) lhref += "index.html";
alert(lhref);

This will also do for all [sub]directories where index.html is the
default.


Sometimes, default.htm, default.asp can also be used


Yes, but ...

clientside there is no way to see which default file is used.

Normally
index.htm,index.html,index.asp
default.htm,default.html,default.asp
etc.

this should not be a problem for clientside coding on the page, since you
will know what page you are coding on, unless you have a linked script.

why not try this:

<script type="text/javascript">var thispagenameis = "index.html"</script>
<script type="text/javascript" src="/lib/mylib.js"></script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3996
by: Kornelius Finkenbein | last post by:
Hello folks! I've got a strange problem with my download-script in conjunction with M$ internet explorer, if the filename I want to link to includes more than one points. In Netscape the problem...
1
1829
by: Yang Li Ke | last post by:
Hey guys! I want to get all pics (.jpg) from a url and I use this code but sometimes with some urls it doesnt work :( Anyone can check it out? $text = implode("", file($url)); $text =...
2
12349
by: Didier FRAISSE | last post by:
i need to retrieve every day an email and to save his attachments for later processing. i found some piece of code in the documentation like import poplib pop = poplib.POP3(Host)...
1
6097
by: Jan | last post by:
Hi, What is the easiest way to retrieve the path from a console application? Right now I am using: - System.Reflection.Assembly.GetEntryAssembly().Location to extract the path and filename -...
6
2471
by: Henke | last post by:
I have a web application that is used to transfer files to and from a database. The files are streamed and stored in the database that is. From one page I can download the files to the client, by...
4
2258
by: ALI-R | last post by:
My home page of my website is named index.aspx ,when I upload it to the host ,I get 403 forbidden error,If I put an index.html there that link that aspx file,eveything works perfect? my second...
6
2176
by: lovecreatesbeauty | last post by:
/* It seems that when an int with width of four bytes is assigned to a one byte width char, the first three bytes from left to right are discarded and the rightest byte is assigned to that char....
4
10899
by: bizt | last post by:
Hi, Im looking for a regular expression to check that a entered filename is valid. I have a cms Im building where the user can enter the name of a file, enter content and then click Save where...
2
4639
by: mndprasad | last post by:
Hi friends, Am new to AJAX coding, In my program am going to have two texbox which going to implent AJAX from same table. One box is going to retrieve the value of other and vice...
0
7225
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
7123
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
5627
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,...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
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
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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.