Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > javascript get current html filename

javascript get current html filename
Thread Tools
Junior Member
Join Date: Nov 2004
Location: Michigan
Status: Offline
Reply With Quote
Nov 22, 2004, 01:56 PM
 
How would I use javascript to get the current html's filename? Thanks in advance!
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Nov 22, 2004, 02:16 PM
 
Use document.location.href to get the whole location, and then there's a number of ways you can go about getting just the documents name.

It depends on what you exactly want to get - if you want the extension included, then:
Code:
function returnDocument() { var file_name = document.location.href; var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?"); return file_name.substring(file_name.lastIndexOf("/")+1, end); }
Or you could use split("/") etc... Like I say - there's a tonne of ways, and it also depends exactly on what you want.

Oh, the above gives you the document name with it's extension, and also takes into account if it has a search string appended on the end.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:22 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2