filename.html missing from location.href
When at the root of a site, without specifying a filename, a usual default of index.html (or even .htm) is loaded; however index.html does not appear in the location.href or location.pathname properties - only what you see in the browser address bar.
If the filename is missing, it will always be the same, right? Assuming you're not using PHP or ASP, it should always be "index.html", so if you're trying to extract a filename from location.href, and none is returned, then simply use a default.
If you are using ASP or PHP, then you can simply output the filename as a variable in the script somewhere on your page using the server functions.
no. while index.html is common, i've seen default.asp, index.htm, default.shtml, and many others and furthermore, it can be almost anything with a custom config.
Originally Posted by HarryAlffa
also, not all pages correspond to files. i've been working a lot in node.js recently, and it doesn't map file to urls at all...
what you have client side is what you see in firebug. period.
why do you need the filename? "/" works just fine for ajax...
Thanks for the replies.
I'm saving the scroll position of a div in a cookie so that it can be retrieved and set when moving between pages. I use the filename to get the correct value for the correct page.
If you assume that it's only the root of the domain which will return no filename, then (for my purposes) any string will do as an identifier, as long as it's unique, but ...
I am using 'if (filename == "") then filename = "index" ' as a stop-gap.
use urls instead of files names. every page already has a unique one.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)