Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy: How can I get the name of the HTML file I am Viewing 2

Status
Not open for further replies.

kstargold

Programmer
Jun 7, 2004
27
0
0
US
How can I get the name of the HTML file I am Viewing? ...as in index.html, mypage.html, or otherpage.shtml

I'm sure this is easy, but I have no idea. I can get the quarystring, but that's not the same.


Thanks,
Kstar
 
I think you need

var tr = window.location.pathname
document.write(window.location.pathname)
 
Code:
<SCRIPT LANGUAGE="javascript">
var here = location.pathname;
queryString = queryString.substring(1, queryString.length);
document.write(here);
</SCRIPT>

This doesn't seem to work, what mistake am I making?

Thanks,
Kstar
 

>> This doesn't seem to work

What doesn't it do that it should be doing?

As far as I can see, the middle line is simply removing the first character of queryString. You should also look at using "substr" instead of "substring" - AFAIK substring will be deprecated at some stage.

Dan
 
Sorry, I needed to add "window."location.pathname

Thanks for replying!!

Kstar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top